Add your description here
Project description
async-progressbar
An asynchronous progress bar for Python, supporting both terminal and Jupyter notebook environments.
Installation
pip install async-progressbar
Usage
Basic Example
import asyncio
from async_progressbar import AsyncProgressBar
async def main():
total = 100
bar = AsyncProgressBar(total)
for _ in range(total):
await asyncio.sleep(0.01)
await bar.update(1)
await bar.finish()
asyncio.run(main())
With aiolimiter (rate-limited requests)
import asyncio
import random
import time
from async_progressbar import AsyncProgressBar
import aiolimiter
number_of_requests = 1000
rate_limiter = aiolimiter.AsyncLimiter(500, 1)
progressbar = AsyncProgressBar(number_of_requests)
async def request(i):
async with rate_limiter:
await progressbar.update(1)
await asyncio.sleep(random.random() * 0.01)
return i
async def main():
await asyncio.gather(*(request(i) for i in range(number_of_requests)))
await progressbar.finish()
if __name__ == "__main__":
t1 = time.time()
asyncio.run(main())
print(f"Total time: {time.time() - t1:.2f} seconds")
In Jupyter Notebooks
The progress bar will automatically use an interactive widget if run in a Jupyter notebook.
API
AsyncProgressBar(total, leave=True, prefix="", suffix="", fill="█", minimum_interval=0.1)update(progress=1): Increment the progress bar.draw(): Redraw the progress bar.finish(): Mark the progress bar as finished.reset(): Reset the progress bar.
Testing
To run the tests:
pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
async_progressbar-0.1.0.tar.gz
(29.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file async_progressbar-0.1.0.tar.gz.
File metadata
- Download URL: async_progressbar-0.1.0.tar.gz
- Upload date:
- Size: 29.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8c07028e3af8b125101d92ca381af8de605334a7e92b5ce976c6f25d7537a3f
|
|
| MD5 |
e09e0adde049114c26726f967bf1470d
|
|
| BLAKE2b-256 |
9572afa5c2d37b2e2d37d3cf3e5b0cef57d29aebc64cf50c047f642ca013d43c
|
File details
Details for the file async_progressbar-0.1.0-py3-none-any.whl.
File metadata
- Download URL: async_progressbar-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70f215822c387a3a34e1fd461667b5e24fc24b918dbff3653491b106da046593
|
|
| MD5 |
cbb620ddb9f0cdd32f6705cbf5e8be5f
|
|
| BLAKE2b-256 |
997ccc9a30aac96d7c949bd06546e61a104958864b54358ab34a05975c76cdd1
|