Metadata-Version: 2.5
Name: abide
Version: 0.0.3
Summary: Cross-process concurrency gate with leased lock-file slots.
Project-URL: Homepage, https://pypi.org/project/abide/
Author-email: lqxnjk <lqxnjk@qq.com>
License: MIT
License-File: LICENSE
Keywords: concurrency,lock,multiprocess,semaphore,throttle
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# abide

[English](#english) | 中文

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

## 安装

```console
pip install abide
```

## 用法

```python
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

---

<a id="english"></a>
## English

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

## Install

```console
pip install abide
```

## Usage

```python
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
