Throttler for asyncio Python
Project description
aiothrottler
Throttler for asyncio Python
Installation
pip install aiothrottler
Example: multiple tasks throttled
import asyncio
import time
from aiothrottler import Throttler
async def main():
# Allows one resolve every 0.5 seoncds
throttler = Throttler(0.5)
await asyncio.gather(*[
worker(throttler) for _ in range(10)
])
async def worker(throttler):
await throttler()
# Will call print 0.5 seconds after the previous call
print(time.time())
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()
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
aiothrottler-0.0.1.tar.gz
(1.9 kB
view hashes)
Built Distribution
Close
Hashes for aiothrottler-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c899fa8f1a07ec94e8dc0b47cdee68027def414e19dd536310eb17b10592ef3c |
|
MD5 | 30442e0c437720e86619d7123c1b705f |
|
BLAKE2b-256 | ff945bf0f7bf444463be6baed5d1cc93d075ce04c16a034e3ba2733b6f72d95a |