Skip to main content

abide

English | 中文

跨进程并发闸:用锁文件把同时进行的操作数压在容量以内。

安装

pip install abide

用法

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()

说明

名额是共享目录里的 slot-<i>.lock 文件,O_EXCL 抢占,因此多进程、多机共享同一目录都拦得住。持有者被强杀时,超过 n_ttl 秒的过期名额会被下一个申请者回收。不可重入:嵌套 with 各占一个名额。

许可证

MIT


English

Cross-process concurrency gate with leased lock-file slots.

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()

Notes

Slots are slot-<i>.lock files created with O_EXCL in a shared directory, so the limit holds across processes and machines. A slot older than n_ttl is reclaimed from a dead holder. Not re-entrant: nested blocks each take a slot.

License

MIT

Metadata

Release files for abide 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for abide 0.0.4
File Size Uploaded Provenance Actions
abide-0.0.4.tar.gz 3.9 kB Without provenance Details for abide-0.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for abide 0.0.4
File Interpreter ABI Platform Actions
abide-0.0.4-py3-none-any.whl Python 3 none any Details for abide-0.0.4-py3-none-any.whl

Total release size: 8.1 kB

Release files / abide-0.0.4.tar.gz

Download URL abide-0.0.4.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2092347bcf52ccd1b7c4963b1bc4f363228cf9d7d6ab1a8eaf25bb99925cd524
BLAKE2b-256 checksum
How to use checksums
ef067aba313f70914f04d5228f132e9c307c4aea1ade4532535aca299845ea6e
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.4-py3-none-any.whl

Download URL abide-0.0.4-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
414975b64852db385036cdf90000c5811e2b6ead8c0e8302fafd4cf8a461a4cc
BLAKE2b-256 checksum
How to use checksums
05c097b25742aed578dd8ca2afe15cc166806f90f487f092c2bbe69e93231d67
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.4

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page