Flow Control
-
功能
- 这个packages可以控制间隔固定的时间一个函数或者语句的调用次数(QPS),可以设置访问次数和时间间隔,
- 访问限制 访问次数/时间间隔
-
使用方法(单进程情况下使用FlowControl 类,多进程情况下使用ProcessFlowControl类)
# encoding=utf-8 import os import threading from datetime import datetime from flow_control.controller import FlowController from flow_control.controller import ProcessFlowController from flow_control.controller import AverageFlowControl from flow_control.controller import AverageProcessFlowControl from threading import Thread def work(flowcontrol): while True: if flowcontrol.get(): print("{}--{}--{}".format(os.getpid(), threading.currentThread().ident, datetime.now())) flow_control = AverageFlowControl(num=0.5, interval=1) Thread(target=work, args=(flow_control,)).start() work(flow_control)
- 创建一个FlowControl (单进程情况下)或者 ProcessFlowControl(多进程情况下) 对象,参数为(num=访问次数,interval=时间间隔),
- 然后调用该对象的 get方法
- 如果get方法返回 True,则说明可以未达到流控限制,如果返回False则说明函数调用次数或者访问次数已经 达到流控限制,应该拒绝调用或访问
Metadata
Release files for flow-control 2.0.0
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 |
|---|---|---|---|---|
| flow_control-2.0.0.tar.gz | 3.1 kB | Without provenance | Details for flow_control-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flow_control-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for flow_control-2.0.0-py3-none-any.whl |
Total release size: 6.9 kB
Release files / flow_control-2.0.0.tar.gz
| Download URL | flow_control-2.0.0.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8031459cf49075b2587788d368012aade737b9912f731437a573c6c8542f8eb9
|
|
BLAKE2b-256 checksum How to use checksums |
00a1f5d6a9ccb79bd54401e59986cd019a57cffa3b7bcdbc4b511b978a742d93
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.13
|
Release files / flow_control-2.0.0-py3-none-any.whl
| Download URL | flow_control-2.0.0-py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ad4f2dd3e8fef4442c0c21075cf63247932ea076886b5ccf914add7f7584fc98
|
|
BLAKE2b-256 checksum How to use checksums |
a804be4a51fe9b9cb4fc44bc23d58401be2c5f0c455b6c2d3cc20c1d00532aa7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.13
|
Security for flow-control 2.0.0
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.