Skip to main content

A robust and versatile throttling implementation relying on the token bucket algorithm.

Project description


The throttle library provides a robust and versatile throttling mechanism for Python.

It can be used in multiple environments, from a single thread to a distributed
server cluster.

It supports Python versions 2.6 to 3.3.


In order to perform throttling tasks, simply use the :meth:`~throttle.throttle`

.. code-block:: python

import throttle

def some_fun(uid):
if not throttle.check(key=uid, rate=30, size=10):
raise ThrottleError()
# Do the job


throttle uses the "token bucket" algorithm: for each key, a virtual bucket

Whenever a new request gets in, the algorithm performs the following actions:

- Test if adding the request's cost to the bucket would exceed its capacity;
in that case, return False
- Otherwise, add the request's cost to the bucket, and return True

Simultaneously, the bucket's current value is decremented at the chosen rate.

This allows for temporary bursts and average computations.


From pip (

.. code-block:: sh

$ pip install throttle

From Github:

.. code-block:: sh

$ git clone git://

Project details

Release history Release notifications

This version
History Node


History Node


History Node


History Node


History Node


Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
throttle-memcache-0.1.5.tar.gz (5.6 kB) Copy SHA256 hash SHA256 Source None Mar 8, 2016

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page