Skip to main content

Throttles for Python coroutines.

Project description

https://img.shields.io/badge/license-BSD-blue.svg https://img.shields.io/pypi/v/aiothrottles.svg https://img.shields.io/pypi/pyversions/aiothrottles.svg https://readthedocs.org/projects/aiothrottles/badge/?version=latest

aiothrottles

aiothrottles synchronization primitives are designed to be extension to asyncio synchronization primitives.

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}"

rate 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.6, 3.7, 3.8 and 3.9 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


Download files

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

Source Distribution

aiothrottles-0.2.0a0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

aiothrottles-0.2.0a0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file aiothrottles-0.2.0a0.tar.gz.

File metadata

  • Download URL: aiothrottles-0.2.0a0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.12

File hashes

Hashes for aiothrottles-0.2.0a0.tar.gz
Algorithm Hash digest
SHA256 cb931f0139ad4c2cf7c6a7b53e81a8b351a1f818f67050783dc6c0aad0fac264
MD5 174875429e4f4f8fcf43a5225d6061e5
BLAKE2b-256 57e9cb65016ae6084e0766e53926f4caa4e2a08a5e0d19ac8a8bce2356654da4

See more details on using hashes here.

File details

Details for the file aiothrottles-0.2.0a0-py3-none-any.whl.

File metadata

File hashes

Hashes for aiothrottles-0.2.0a0-py3-none-any.whl
Algorithm Hash digest
SHA256 3a6d5c21c8938e11ce8035a30fb6553b9400c27217d0c72b0787712ba877bf4f
MD5 8472a64f92329158c122f6551c92d5eb
BLAKE2b-256 d551facb1931c16c2e41b13850e2d759946b7c1970190d242ef5e02cbc40baca

See more details on using hashes here.

Supported by

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