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 Distributions
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.2-py3-none-any.whl.
File metadata
- Download URL: async_progressbar-0.1.2-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
038704def19d3f1071794317e7440774671317446439b2c230ca6641ab89ed7f
|
|
| MD5 |
9299093f6bc049f2e89955e53d060de2
|
|
| BLAKE2b-256 |
6f3a5d50c3387586bdcaf0adbef6e75a6c11ff21e59fd52b4b05e7aaaa4d3509
|
Provenance
The following attestation bundles were made for async_progressbar-0.1.2-py3-none-any.whl:
Publisher:
publish-pypi.yml on thomasaarholt/async-progressbar
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
async_progressbar-0.1.2-py3-none-any.whl -
Subject digest:
038704def19d3f1071794317e7440774671317446439b2c230ca6641ab89ed7f - Sigstore transparency entry: 410348794
- Sigstore integration time:
-
Permalink:
thomasaarholt/async-progressbar@7c8194c6fd059c9c82217d5fe39165238dfa581e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/thomasaarholt
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@7c8194c6fd059c9c82217d5fe39165238dfa581e -
Trigger Event:
workflow_dispatch
-
Statement type: