RateLimitQueue
A rate limited wrapper for Python's thread safe queues.
Some external APIs have rate limits that allow faster-than-consecutive queries, e.g. if the rate limit is very high or the API response is quite slow. To make the most of the API, the best option is often to make API calls from multiple threads. Then you can put the requests or URLs to call in a queue.Queue and have the threads consume the URLs as they make the calls. However, you still have to make sure that the total calls from all your threads don't exceed the rate limit, which requires some nontrivial coordination.
The ratelimitqueue package extends the three built-in Python queues from from queue package - Queue, LifeQueue, and PriorityQueue - with configurable, rate limited counterparts. Specifically, the get() method is rate limited across all threads so that workers can safely consume from the queue in an unlimited loop, and putting the items in the queue doesn't need to require blocking the main thread.
Installation
To get started, install it with pip:
pip install ratelimitqueue
Metadata
Release files for ratelimitqueue 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ratelimitqueue-0.2.2.tar.gz | 4.7 kB | Details |
Release files / ratelimitqueue-0.2.2.tar.gz
| Download URL | ratelimitqueue-0.2.2.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ae4123ef5033e2028a52e9857b213cd3e86576161d6a3fccc5e7a75cce229998
|
|
BLAKE2b-256 checksum How to use checksums |
e663c55beb712d49c08024e437d6881dcb69763026cb29236fe966e495ae1b7d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.1.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.3
|