A lightweight Python decorator toolkit for probabilistic, delayed, and throttled execution.
Project description
probctrl
probctrl 是一个轻量的 Python 装饰器库,支持三种函数执行控制方式:
@p(prob):按概率触发函数@delay(seconds):延迟指定秒数后异步执行@throttle(rate):限制函数每秒最大调用频率,超过频率后将自动延迟执行
安装
pip install probctrl
示例
from probctrl import p, delay, throttle
@p(0.5)
def maybe_func():
print("有 50% 的概率会执行")
@delay(2)
def delayed_func():
print("这个函数会延迟 2 秒异步执行")
@throttle(3)
def throttled_func():
print("受节流控制的函数")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
probctrl-0.1.2.tar.gz
(2.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file probctrl-0.1.2.tar.gz.
File metadata
- Download URL: probctrl-0.1.2.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
205ae42f1bed043edc01f48a82813fabe41c677316c53ef352537cb1b6f9f473
|
|
| MD5 |
fad72e94cbfebd14d693162db3607c5d
|
|
| BLAKE2b-256 |
69fa24f23a9750c0325adb619b1fd19588cb311cc29770e03e8c84aed189d2fe
|
File details
Details for the file probctrl-0.1.2-py3-none-any.whl.
File metadata
- Download URL: probctrl-0.1.2-py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b769c89239cb90c5ecb552bb5a0eee8bc77a41e2a0d73871e83a628c947d7f8b
|
|
| MD5 |
2ac0ae823e7c15e482581787a68e8da5
|
|
| BLAKE2b-256 |
2b879c058cbe6b9e98416d52c0c1738692b25c541fffbe809b4e21b90cd1d686
|