Thread-safe rate limit semaphore for threading and async/await style built on Rust
Project description
Ralipyard
Python thread-safe rate limit semaphore for threading and async/await style built on Rust's library raliguard
Overview
For example, crate a semaphore that allows only 5 calls per 1 second
import asyncio
import time
import datetime
import ralipyard
async def task(sem: ralipyard.Semaphore, no: int):
delay = sem.calc_delay()
await asyncio.sleep(delay)
print(f"Task {no=} executes its code at {time.monotonic():.5f}")
async def main():
sem = ralipyard.Semaphore(
access_times=5,
per_period=datetime.timedelta(seconds=1)
)
tasks = [task(sem, i) for i in range(100)]
await asyncio.gather(*tasks)
asyncio.run(main())
Output:
Task no=0 executes its code at 0.21575
Task no=4 executes its code at 1.22018
Task no=3 executes its code at 1.22022
Task no=2 executes its code at 1.22023
Task no=1 executes its code at 1.22024
Task no=9 executes its code at 2.21618
Task no=7 executes its code at 2.21622
Task no=8 executes its code at 2.21623
Task no=6 executes its code at 2.21624
Task no=5 executes its code at 2.21624
Task no=11 executes its code at 3.22016
Task no=10 executes its code at 3.22020
Task no=12 executes its code at 3.22021
Task no=14 executes its code at 3.22022
Task no=13 executes its code at 3.22023
...
Instalation
From PyPI:
python -m pip install ralipyard
Or from GitHub
python -m pip install https://github.com/deknowny/archive/ralipyard.zip
Documentation
It's unnecessary because the library has the only 1 class with the only 2 methods, visit stubs for more information
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
ralipyard-0.1.0.tar.gz
(5.5 kB
view hashes)
Built Distributions
Close
Hashes for ralipyard-0.1.0-pp37-pypy37_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d877c3884275f3dd44e850791232daa115a8d51883b493eb3d3c138400835903 |
|
MD5 | a8a4cb89ab1b14fcb822df658d4a2d3c |
|
BLAKE2b-256 | 9ab9ebbc1e7f922830ac3197ee9f8383a1d78d036fabccf7f1dfe46cf0ed324a |
Close
Hashes for ralipyard-0.1.0-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5fbffd7d753750ecfbdb04e1379e31d98a7b81e7c11faded499648f3fed9e5f4 |
|
MD5 | c9326a229aa83b053ef07b9fde54a15e |
|
BLAKE2b-256 | f53cf639ed4a6baa481d7070c60b76451bf1a538b703868d2b1538e235d99a7b |
Close
Hashes for ralipyard-0.1.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ca78180d1501277f1ee858be8b7694985441c12f7e55db05d424af8c50b1639 |
|
MD5 | c2f63839624898816e59c2ba93d301f5 |
|
BLAKE2b-256 | 0c167be5b6e887fdbc95499817322991bdc9064ff29234d7cd757b6655258c94 |
Close
Hashes for ralipyard-0.1.0-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 459e1d6be5707a1e898e0bacaa90d1f4672eb86dabc11b75faa6fe0d32f6f574 |
|
MD5 | df33496513940b9102c4992ff02ef870 |
|
BLAKE2b-256 | 0be10f6ccd5295e6754222a3113f0c4d8d21d9d81ea1d6d4efc724cb88bf83cb |
Close
Hashes for ralipyard-0.1.0-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 583f82f82bd9771a4f929c39b3b863915f2517ddc07dfff8aeeaee5df1a24d69 |
|
MD5 | 5fa60c4732cc901dec7e3dd75a699e6c |
|
BLAKE2b-256 | 50a52275ffb02ee948130fdfe706d2f353b2664586d1834c6c3ccf310c52ac8f |
Close
Hashes for ralipyard-0.1.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3cbd3d1f7bf3d844ddf6bf0ae9858ea75edd2f6194a25e62d950a24469bfda1f |
|
MD5 | 29eb9f98fa0502bdf3de185a5daf1e1e |
|
BLAKE2b-256 | e71d47fa3f93231bcf1fe8f8b19490188ba7557fbee0fe790821cbf75c7e4c11 |
Close
Hashes for ralipyard-0.1.0-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2dfbf90aae9944297382ae4f80817546110e377874ffc5d5a6693ca4e7650fca |
|
MD5 | 0331cc668e9894059b0fec4ec546e99e |
|
BLAKE2b-256 | ab7090a7950edd672afcbd4c8fa5b1c23c0bc41d41cabe31c4b477bd5fce5db5 |
Close
Hashes for ralipyard-0.1.0-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fcdd592ae991fb7637b3b923cc7febbe5bf8484a4ca881c8f31a95ac56bc7ea4 |
|
MD5 | f0b44f94e5f4cafee195f3faecc2ea18 |
|
BLAKE2b-256 | 0eae7de8432c0d07ec51ac2ebe6726e46c95fa70b0ef04e4678c6f082c56abc2 |
Close
Hashes for ralipyard-0.1.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29dc3e6cceaccdb7abee32fedc4429f3f1a0da182e8670558267dfdec676dd4c |
|
MD5 | bed2bf81784a878a486073fdef9acfbe |
|
BLAKE2b-256 | d787dcbc151a6ca491f090674d61e4dfb4b318f70851a29412f3efb07c809f09 |
Close
Hashes for ralipyard-0.1.0-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb2282d996e42b2bae3c7fa8d2588d387e24be9369364284f854e029e4505a81 |
|
MD5 | 55c34e6f6d5baedb90e0074dcfd88b4a |
|
BLAKE2b-256 | 19826d2385020b70a7ef223df67fa8ae6fb16d1fd12c50b65bcdd8e3e4589fd7 |
Close
Hashes for ralipyard-0.1.0-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9a9da3d0de20df098e2073e9f8ba597fed9a5836dc0e62aff0ac81b1977354e |
|
MD5 | 72537e51bc03ba6350bed2401487b666 |
|
BLAKE2b-256 | 77ea99bb24fc4a77cb79309699145f8b4b9c50900dfdda2331708969eba6fdaa |
Close
Hashes for ralipyard-0.1.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41b51f13524028d2a23e75910b8869989ffba3f55c6f6c8a7bf10cd505b7a001 |
|
MD5 | 6144be1e55bae4014606ff4762280bec |
|
BLAKE2b-256 | aa94c7bcbda97d9d1e8dae7164fbc07ca6a9ef54206b23c0434b40d7ad971dbd |
Close
Hashes for ralipyard-0.1.0-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6f7426d825a724f6dbf058ad8b773000901ff7a5d0aadb6eb2e9ccae8fffa3e |
|
MD5 | d55f52150c5f0a1d42f23c504d24ca99 |
|
BLAKE2b-256 | 27c497ec5bc1942ca9f35fbde474ad11fc34f9b0e17f42388ec19aa20f8e7856 |