Skip to main content

Rate limit semaphore for async-style (any core)

Project description

Rate Limit Semaphore

Rate limit semaphore for async-style (any core)

PyPI - Python Version PyPI - Implementation PyPI Coverage Status


There are two implementations of rate limit semaphore. Live demo shows how FixedNewPreviousDelaySemaphore and FixedNewFirstDelaySemaphore work


Live demo Live demo

Overview

import datetime
import ralisem

# Or another implementation
sem = ralisem.FixedNewPreviousDelaySemaphore(
    access_times=3, per=datetime.timedelta(seconds=1)
)
async with sem:
    ...

Difference:

  • FixedNewPreviousDelaySemaphore: Sures the last and a new access have a fixed required delay (per / access_times)
  • FixedNewFirstDelaySemaphore: Sures first and last in series (serias is access_times) have a fixed delay (per)

Methods

All of these implementations are inherited from one base TimeRateLimitSemaphoreBase. Check out full methods here

Installation

Via PyPI:

python -m pip install ralisem

Or via GitHub

python -m pip install https://github.com/deknowny/rate-limit-semaphore/archive/main.zip

Contributing

Check out Contributing section

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

ralisem-0.1.0.tar.gz (4.2 kB view hashes)

Uploaded Source

Built Distribution

ralisem-0.1.0-py3-none-any.whl (4.1 kB view hashes)

Uploaded Python 3

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