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

GitHub

View Github