Skip to main content

A simple throttling package

Project description

This library is inspired by this book and this implementation https://github.com/vostok/throttling.

Features:

  1. Set capacity(max parallel requests) and queue(max queued requests) limits.
  2. Per-consumer limits. For instance, to not allow any consumer to use more than 70% of service's capacity.
  3. Per-request priorities. For instance, to not allow requests with lowest priority to be queued or to now allow requests with normal priority to use more than 90% of service's capacity.

Example:

from aio_throttle import Throttler, MaxFractionCapacityQuota, ThrottlePriority, ThrottleResult

capacity_limit = 100
queue_limit = 200
consumer_quotas = [MaxFractionCapacityQuota(0.7)]
priority_quotas = [MaxFractionCapacityQuota(0.9, ThrottlePriority.NORMAL)]
throttler = Throttler(capacity_limit, queue_limit, consumer_quotas, priority_quotas)

async with throttler.throttle(consumer, priority) as result:
    ... # check if result is ThrottleResult.ACCEPTED or not

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

aio-throttle-1.3.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aio_throttle-1.3.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file aio-throttle-1.3.0.tar.gz.

File metadata

  • Download URL: aio-throttle-1.3.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for aio-throttle-1.3.0.tar.gz
Algorithm Hash digest
SHA256 38ddb8d297d4fbd986e1f8fd0c52f645e21818def2fc9aaa295cad8471c2166b
MD5 4055acf1ebb4720a9550abcae7f4a7a6
BLAKE2b-256 c0dc2e65d1b045b49e5e60e41e8d0b2c4c2fffd5ce11e40821bb873b50b204ba

See more details on using hashes here.

File details

Details for the file aio_throttle-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: aio_throttle-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for aio_throttle-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5020d8007a80fbaac537e8532329a157655e59bfd436821834a2c63a69c2e3a3
MD5 68512e06e74b0cb74d154de468267383
BLAKE2b-256 117dc2391dc769a881f1d1f1e7f1a9eeb828065695aa4ee593256b0e4ce137e2

See more details on using hashes here.

Supported by

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