Skip to main content

Thread-safe rate limit semaphore for threading and async/await style built on Rust

Project description

Ralipyard

PyPI - Python Version PyPI - Implementation PyPI

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


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 details)

Uploaded Source

Built Distributions

ralipyard-0.1.0-pp37-pypy37_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.whl (985.9 kB view details)

Uploaded PyPy manylinux: glibc 2.5+ x86-64

ralipyard-0.1.0-cp310-none-win_amd64.whl (121.1 kB view details)

Uploaded CPython 3.10 Windows x86-64

ralipyard-0.1.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.whl (983.6 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.5+ x86-64

ralipyard-0.1.0-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (439.3 kB view details)

Uploaded CPython 3.10 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

ralipyard-0.1.0-cp39-none-win_amd64.whl (121.4 kB view details)

Uploaded CPython 3.9 Windows x86-64

ralipyard-0.1.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl (983.9 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.5+ x86-64

ralipyard-0.1.0-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (439.5 kB view details)

Uploaded CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

ralipyard-0.1.0-cp38-none-win_amd64.whl (121.1 kB view details)

Uploaded CPython 3.8 Windows x86-64

ralipyard-0.1.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl (983.2 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.5+ x86-64

ralipyard-0.1.0-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (439.1 kB view details)

Uploaded CPython 3.8 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

ralipyard-0.1.0-cp37-none-win_amd64.whl (121.0 kB view details)

Uploaded CPython 3.7 Windows x86-64

ralipyard-0.1.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (983.3 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.5+ x86-64

ralipyard-0.1.0-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (439.2 kB view details)

Uploaded CPython 3.7m macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

File details

Details for the file ralipyard-0.1.0.tar.gz.

File metadata

  • Download URL: ralipyard-0.1.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/0.12.17

File hashes

Hashes for ralipyard-0.1.0.tar.gz
Algorithm Hash digest
SHA256 abd621531909163c8e084e1aba9db22f73627a7bc755d8aa3559e8017ca65dac
MD5 e9d097304acb26f1149abb5b71e5bfc0
BLAKE2b-256 1517187acd86d870fc40865f8d9cee706ba97784151cc7d4b5f96af3a32ba6fc

See more details on using hashes here.

File details

Details for the file ralipyard-0.1.0-pp37-pypy37_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

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

See more details on using hashes here.

File details

Details for the file ralipyard-0.1.0-cp310-none-win_amd64.whl.

File metadata

File hashes

Hashes for ralipyard-0.1.0-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 5fbffd7d753750ecfbdb04e1379e31d98a7b81e7c11faded499648f3fed9e5f4
MD5 c9326a229aa83b053ef07b9fde54a15e
BLAKE2b-256 f53cf639ed4a6baa481d7070c60b76451bf1a538b703868d2b1538e235d99a7b

See more details on using hashes here.

File details

Details for the file ralipyard-0.1.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

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

See more details on using hashes here.

File details

Details for the file ralipyard-0.1.0-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.

File metadata

File hashes

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

See more details on using hashes here.

File details

Details for the file ralipyard-0.1.0-cp39-none-win_amd64.whl.

File metadata

File hashes

Hashes for ralipyard-0.1.0-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 583f82f82bd9771a4f929c39b3b863915f2517ddc07dfff8aeeaee5df1a24d69
MD5 5fa60c4732cc901dec7e3dd75a699e6c
BLAKE2b-256 50a52275ffb02ee948130fdfe706d2f353b2664586d1834c6c3ccf310c52ac8f

See more details on using hashes here.

File details

Details for the file ralipyard-0.1.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

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

See more details on using hashes here.

File details

Details for the file ralipyard-0.1.0-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.

File metadata

File hashes

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

See more details on using hashes here.

File details

Details for the file ralipyard-0.1.0-cp38-none-win_amd64.whl.

File metadata

File hashes

Hashes for ralipyard-0.1.0-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 fcdd592ae991fb7637b3b923cc7febbe5bf8484a4ca881c8f31a95ac56bc7ea4
MD5 f0b44f94e5f4cafee195f3faecc2ea18
BLAKE2b-256 0eae7de8432c0d07ec51ac2ebe6726e46c95fa70b0ef04e4678c6f082c56abc2

See more details on using hashes here.

File details

Details for the file ralipyard-0.1.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

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

See more details on using hashes here.

File details

Details for the file ralipyard-0.1.0-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.

File metadata

File hashes

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

See more details on using hashes here.

File details

Details for the file ralipyard-0.1.0-cp37-none-win_amd64.whl.

File metadata

File hashes

Hashes for ralipyard-0.1.0-cp37-none-win_amd64.whl
Algorithm Hash digest
SHA256 f9a9da3d0de20df098e2073e9f8ba597fed9a5836dc0e62aff0ac81b1977354e
MD5 72537e51bc03ba6350bed2401487b666
BLAKE2b-256 77ea99bb24fc4a77cb79309699145f8b4b9c50900dfdda2331708969eba6fdaa

See more details on using hashes here.

File details

Details for the file ralipyard-0.1.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

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

See more details on using hashes here.

File details

Details for the file ralipyard-0.1.0-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.

File metadata

File hashes

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

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page