abide
Cap how many processes hit a resource at once — using only lock files, so it works across processes and across machines sharing a directory.
Install
pip install abide
Usage
from abide import GateLock
gate = GateLock("./locks", m_capacity=4, n_ttl=120, n_timeout=30)
with gate.slot() as index:
call_the_rate_limited_api()
Why not threading.Semaphore
A semaphore lives in one process. Nine worker processes each opening eight threads means 72 concurrent requests, no matter what each process believes. Slot files on disk are shared by everyone.
Behaviour
| Aspect | Detail |
|---|---|
| Slot storage | slot-<i>.lock files created with O_EXCL |
| Crashed holder | slot older than n_ttl seconds is reclaimed |
| No free slot | waits, then raises SlotTimeout |
| Re-entrancy | not re-entrant: nested with blocks each take a slot |
TimeoutError (via SlotTimeout) is raised rather than blocking forever — a
gate that never opens is a deadlock, not a feature.
License
MIT
Metadata
Release files for abide 0.0.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 | Provenance | Actions |
|---|---|---|---|---|
| abide-0.0.2.tar.gz | 3.7 kB | Without provenance | Details for abide-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| abide-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for abide-0.0.2-py3-none-any.whl |
Total release size: 7.8 kB
Release files / abide-0.0.2.tar.gz
| Download URL | abide-0.0.2.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
09a32ea386faf910fd3f614e06cb43e8a0ea62a19ed5c53dcef7c70128d2291c
|
|
BLAKE2b-256 checksum How to use checksums |
ddb19ca6d71bd94a0d7a3e9b10faa489e204964c5e31cf605f903cad5c9ab4fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.11
|
Release files / abide-0.0.2-py3-none-any.whl
| Download URL | abide-0.0.2-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
39088766a851ac02230616db235e8fefb200803f71e9542a8d37df058fa5ff3a
|
|
BLAKE2b-256 checksum How to use checksums |
9d14ad975cf7e6d351438370ba3606cf06c7fe222bb92a452b2943e08f01e920
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.11
|
Security for abide 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.