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://img.shields.io/badge/docs-latest-brightgreen.svg https://travis-ci.org/KonstantinTogoi/aiothrottles.svg

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


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.1.1.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

aiothrottles-0.1.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file aiothrottles-0.1.1.tar.gz.

File metadata

  • Download URL: aiothrottles-0.1.1.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

Hashes for aiothrottles-0.1.1.tar.gz
Algorithm Hash digest
SHA256 71172b12f964ffb6bd26df35d8c5ca5f6ec0fe23f99022799a2d93b272a1ed71
MD5 0d3f3a5fe7e14211f4a7a65a600d27c6
BLAKE2b-256 f128276d3f2ef7fd1adda17b793de6b78a57bb75f45ae1570bef136b01e22dbe

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aiothrottles-0.1.1-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

Hashes for aiothrottles-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a7b9bd72a81348513a0f762aa5e9426d1a2e284560d23623cae1c285568487e0
MD5 9e3993f93338ebd4485afd5f2b4e4db2
BLAKE2b-256 03f3c07a80b37151f69b174b507ba1491592818311ea5673f6cecbd4c5677d57

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