You are here: Home / LBN / Up2date / Core Linux / BastionLinux 36 / python3-asyncio-throttle-1.0.2-1.lbn36.noarch

python3-asyncio-throttle-1.0.2-1.lbn36.noarch

Package Attributes
RPM  python3-asyncio-throttle-1.0.2-1.lbn36.noarch.rpm Architecture  noarch Size  6395 Created  2022/11/22 13:22:52 UTC
Package Specification
Summary Simple, easy-to-use throttler for asyncio
Group Application/Internet
License ZPL
Home Page https://pypi.org/project/asyncio-throttle
Description

asyncio-throttle

Simple, easy-to-use throttler for asyncio. Example import time import random import asyncio

from asyncio_throttle import Throttler

async def worker(no, throttler, n): for _ in range(n): await asyncio.sleep(random.random() * 2)

async with throttler: print(time.time(), Worker #%d: Bang! % no)

async def main(): throttler = Throttler(rate_limit=5)

tasks = [ loop.create_task(worker(no, throttler, 10)) for no in range(5) ] await asyncio.wait(tasks)

loop = asyncio.get_event_loop() loop.run_until_complete(main()) loop.close()

Here I limited work rate to 5/sec while there are 5 workers. And the result: 1508273760.3462772 Worker #2: Bang! 1508273760.590009 Worker #3: Bang! 1508273760.856431 Worker #0: Bang! 1508273761.0110679 Worker #2: Bang! 1508273761.086856 Worker #4: Bang! 1508273761.350699 Worker #3: Bang! 1508273761.5906 Worker #1: Bang! 1508273761.8655958 Worker #4: Bang! 1508273762.224158 Work

Requires
rpmlib(PayloadFilesHavePrefix)  
rpmlib(PayloadIsZstd)  
rpmlib(CompressedFileNames)  
rpmlib(PartialHardlinkSets)  
rpmlib(FileDigests)  
Provides
python-asyncio-throttle
python3-asyncio-throttle
python3.10-asyncio-throttle
python3.10dist(asyncio-throttle)
python3dist(asyncio-throttle)
Obsoletes
python-asyncio-throttle

Document Actions