/pycooldown

A fast cooldown/ratelimit implementation. Archived, consider using https://github.com/lunarmagpie/floodgate instead.

Primary LanguagePythonMIT LicenseMIT

pycooldown

pypi

Documentation | Support

A lightning-fast cooldown/ratelimit implementation.

Example Usage

from pycooldown import FixedCooldown


cooldown = FixedCooldown(period=10, capacity=5)


def handle_event(sender):
    retry_after = cooldown.update_ratelimit(sender)
    if retry_after is None:
        print("Event succeeded!")
    else:
        print(f"Too many events from {sender}. Retry in {retry_after} seconds.")