Throttles for Python coroutines.
Project description
aiothrottles
aiothrottles synchronization primitives are designed to be extension (along the time) to asyncio synchronization primitives.
aiothrottles has the following basic synchronization primitives:
Throttle
For more details, see aiothrottles Documentation.
Usage
Throttle implements a rate limiting for asyncio task. A throttle can be used to guarantee limited access to a shared resources.
The preferred way to use a Throttle is an async with statement:
throttle = Throttle('3/s')
# ... later
async with throttle:
# access shared state
which is equivalent to:
throttle = Throttle('3/s')
# ... later
await throttle.acquire()
try:
# access shared state
finally:
throttle.release()
A call rate is determined by the rate
argument.
Pass the rate in the following formats:
"{integer limit}/{unit time}"
"{limit's numerator}/{limit's denominator}{unit time}"
Examples:
4/s
,5/m
,6/h
,7/d
1/second
,2/minute
,3/hour
,4/day
1/3s
,12/37m
,1/5h
,8/3d
Installation
pip install aiothrottles
or
python setup.py install
Supported Python Versions
Python 3.5, 3.6, 3.7 and 3.8 are supported.
Test
Run all tests.
python setup.py test
Run tests with PyTest.
python -m pytest [-k TEST_NAME] [-m MARKER]
License
aiothrottles is released under the BSD 3-Clause License.
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
Built Distribution
File details
Details for the file aiothrottles-0.1.0rc1.tar.gz
.
File metadata
- Download URL: aiothrottles-0.1.0rc1.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.5.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7cbc16e8903c6af92938576769a46c71108c3511215755bfcb62dd1e3ee70396 |
|
MD5 | 6c7fc84e9384ebc7a466e16439bf44f5 |
|
BLAKE2b-256 | 3d056aefa5a41fce187825bc175c73ffc64582ae293dc8f6e5dffad98ed8a505 |
File details
Details for the file aiothrottles-0.1.0rc1-py3-none-any.whl
.
File metadata
- Download URL: aiothrottles-0.1.0rc1-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.5.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19aef7b856c163b7af5d1fb52bdf7e40fcdcc128f290e74494bdd8c7b20f46f7 |
|
MD5 | 2e1d21cb4512b263ad171df5c09f6272 |
|
BLAKE2b-256 | 5b04238cc8cdbbfd63b2b643a6851f557188743d523be41bbd1ee546551cfffd |