Rate Limit Components
Project description
version: 0.1.4
pip install ratelimiter_lite
Demo Usage:
import time
from concurrent.futures.thread import ThreadPoolExecutor
from ratelimiter_lite.factory import ratelimiter_lite_factory
from ratelimiter_lite.fixed_window import FixedWindowratelimiter
@ratelimiter_factory(FixedWindowratelimiter, limit=2, period=0.3)
def task(args):
print(f"task: {args}")
def test_fixed_window():
# limit worker count,observe ratelimiter_lite functions.
with ThreadPoolExecutor(max_workers=5) as p:
period = 2.0
start = time.monotonic()
while True:
if time.monotonic() - start > period:
break
p.submit(task, "running.")
# wait thread for a while, the period should less than limiter's `period/limit`
time.sleep(0.05)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 ratelimiter_lite-0.1.4.tar.gz.
File metadata
- Download URL: ratelimiter_lite-0.1.4.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.4 CPython/3.12.13 Linux/6.6.87.1-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29d62a6f1cab16530b27670c821a6297b882abf2a935597d35f5d3e9225871ae
|
|
| MD5 |
80e63fd64e61a879469a000fdeaff078
|
|
| BLAKE2b-256 |
7b793e432e783f3fba1a3f43af6d52c4d544e7b6b0d3bdace1418511b5a77d07
|
File details
Details for the file ratelimiter_lite-0.1.4-py3-none-any.whl.
File metadata
- Download URL: ratelimiter_lite-0.1.4-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.4 CPython/3.12.13 Linux/6.6.87.1-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01d80ab662cc7336e312ceb7ddf3ea20f3e9d3f8b55dc9771bc842a7dfc90beb
|
|
| MD5 |
c6e5766a6453b8b45611c1fbe4b6833c
|
|
| BLAKE2b-256 |
02c9ed640a8244c73e74148160e52e72262997783f74eab065c1ab490cf02994
|