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.1.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.1.tar.gz.
File metadata
- Download URL: probctrl-0.1.1.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 |
838c99e77589ff19f9f5f20e3a9c2742fccf04b34282a3f4fc21cb5451ca2d1e
|
|
| MD5 |
d01bf210c93b84ff6f002eff02fc3366
|
|
| BLAKE2b-256 |
a983bb15d6641d69790fb94b3a8fd68e6b001632b80aae9659101ad58d7022af
|
File details
Details for the file probctrl-0.1.1-py3-none-any.whl.
File metadata
- Download URL: probctrl-0.1.1-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 |
f08dab6b05f1e1d493fcd033558be2c634235801540e8be8412e6a5c4bcbc40f
|
|
| MD5 |
9f6da6294256287416570066f986b913
|
|
| BLAKE2b-256 |
24fd6139209674c6492d6d3eca04161342340f879659fa4c4c6a28ba31356889
|