Registry / http-networking / throttler

throttler

JSON →
library1.2.3pypypi✓ verified 86d ago

Throttler is a zero-dependency Python package designed for easy rate limiting and concurrency control, with robust support for asyncio. It provides flexible context managers and decorators to manage the frequency and simultaneity of operations. The library is actively maintained, with version 1.2.3 being the latest, and receives updates to support newer Python versions and improve performance.

pip install throttler
INSTALL
IMPORT
SIG · THROTTLER
T
throttler
http-networkingpythonv1.2.3
Install
1.5s avg
Import
203ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.2.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.218s · 17.8MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.5s · import 0.189s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Throttler
from throttler import Throttler
throttle
from throttler import throttle
ThrottlerSimultaneous
from throttler import ThrottlerSimultaneous
throttle_simultaneous
from throttler import throttle_simultaneous
ExecutionTimer
from throttler import ExecutionTimer
execution_timer
from throttler import execution_timer

This quickstart demonstrates using the `Throttler` context manager to rate-limit asynchronous tasks to 3 executions per second. The `asyncio.run()` function is used to execute the main asynchronous function.

import asyncio from throttler import Throttler import time async def limited_task(task_id, throttler): async with throttler: print(f"{time.time():.2f}: Task {task_id} executing...") async def main(): # Limit to 3 calls per second rate_limiter = Throttler(rate_limit=3, period=1.0) tasks = [limited_task(i, rate_limiter) for i in range(10)] await asyncio.gather(*tasks) if __name__ == "__main__": asyncio.run(main())
Debug
Known issues
breakingVersion 1.2.3 dropped official support for Python 3.6 and 3.7. Users on these Python versions should remain on `throttler<1.2.3` to avoid compatibility issues.
fix
Upgrade to Python 3.8+ or pin `throttler` to a version prior to 1.2.3.
affects: >=1.2.3
gotchaBoth `Throttler` and `ThrottlerSimultaneous` are asynchronous context managers or decorators. They must be used within an `async` function and typically require an `asyncio` event loop to run correctly. Attempting to use them synchronously will result in runtime errors.
fix
Ensure usage is within an `async` function and an `asyncio` event loop (e.g., using `asyncio.run()`, `await`).
affects: All
gotchaThe `Throttler` (for rate limiting) implements a sliding window mechanism. This means it tracks the exact timestamps of previous executions within the `period`. If you expect a fixed window behavior, this might lead to different throttling patterns than anticipated.
fix
Understand the sliding window behavior; if a strict fixed window is required, consider implementing custom logic or exploring other libraries.
affects: All
gotchaPrior to version 1.2.1, argument validation for `Throttler` and related classes might have been less robust, potentially leading to unexpected behavior with invalid input values or types. Version 1.2.1 introduced explicit checks for these.
fix
Upgrade to `throttler>=1.2.1` to benefit from improved argument validation and more graceful error handling.
affects: <1.2.1
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'throttler'
The 'throttler' package has not been installed or is not accessible in the current Python environment.
fix
pip install throttler
TypeError: Throttler.__init__ missing 2 required positional arguments: 'rate_limit' and 'period'
The Throttler class constructor requires both 'rate_limit' and 'period' arguments to be provided upon instantiation.
fix
throttler_instance = Throttler(rate_limit=10, period=1)
TypeError: 'Throttler' object is not an async context manager
The Throttler instance is designed to be used as an asynchronous context manager, requiring the 'async with' statement instead of a regular 'with' statement.
fix
async with throttler_instance:
    # your async code here
ImportError: cannot import name 'AsyncThrottler' from 'throttler'
You are attempting to import a class name ('AsyncThrottler') that does not exist or is not exposed directly by the 'throttler' package. The main class is simply named 'Throttler'.
fix
from throttler import Throttler
Upgrade
Version history
1.2.3latest on PyPI · released Jan 27, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
27 hits · last 30 days
node
22
OpenAI (training)
1
Resources
throttler — pip install throttler · libregistry