Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

async_progressbar-0.1.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file async_progressbar-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for async_progressbar-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 defc093a6b2fe9af4146ffe21fd093768221c8d13540610b6cdb7da1d9b57563
MD5 cb53af0e43f51b00d3f7a3cb6689eeef
BLAKE2b-256 a1c53440e8a7797598e4452e61706fd776ba9c34bc0d640cccd15cf675287c37

See more details on using hashes here.

Provenance

The following attestation bundles were made for async_progressbar-0.1.1-py3-none-any.whl:

Publisher: publish-pypi.yml on thomasaarholt/async-progressbar

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page