Skip to main content

Flexible, easy to use rate limiter

Project description

Rerate

Flexible rate limiter in Python, with (soon) multiple algorithms and backend stores.

Installing

pip install rerate

Usage

from rerate import limiter, RateLimitedException
from time import sleep

limit = Limiter(limit=2, period=1, store_option='REDIS', host='localhost', port=6379)

@limit
def example():
    sleep(0.3)
    print('hi')

for _ in range(100):
    try:
        example()
    except RateLimitedException as e:
        print('I got limited!')

Supported Storage Options

  • Redis
  • Local (dictionary)

Supported Algorithms

  • Generic Cell Rate

Todo

  • More backends, more algorithms
  • Better exceptions
  • Built in retry
  • Async

Acknowledgments

A lot of the ideas/code is inspired by:

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

rerate-0.0.2.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rerate-0.0.2-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file rerate-0.0.2.tar.gz.

File metadata

  • Download URL: rerate-0.0.2.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.1

File hashes

Hashes for rerate-0.0.2.tar.gz
Algorithm Hash digest
SHA256 3d349404f6283b3a8abcfd5e4ea802875bb9216bdf07d6ad70ff5486e3c38bb4
MD5 3c1b4ce2781c5a1f345fc2330f00ff7d
BLAKE2b-256 f89b9cc7782dd020e5a50a2710f345f1f2c56689bb4b58808f7e5d47ddc3adbb

See more details on using hashes here.

File details

Details for the file rerate-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: rerate-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.1

File hashes

Hashes for rerate-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5943384a843c5f779b2a8bd014e1e5bc5bf91bf4dcbb547fd3c51c038e11b53a
MD5 492e0237885bfcce8e31e9f3395243d6
BLAKE2b-256 c673f464407d1459e984e3fe7b9b4e0c4422486a220c9167bb081401de487f5f

See more details on using hashes here.

Supported by

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