Skip to main content

Python Rate-Limiter using Leaky-Bucket Algorimth Family

Project description

Request Rate Limiter using Leaky-bucket algorimth

Introduction

This module can be used to apply rate-limit for API request, using leaky-bucket algorimth. User defines window duration and the limit of function calls within such interval.

Currently this package requires Redis to work with.

Installation

$ pip install pyrate-limiter

Usage

from pyrate_limiter.core import RedisBucket as Bucket, HitRate

# Init bucket singleton
bucket = Bucket('redis-url', prefix='redis-prefix')

# Init rate_limiter
limiter = HitRate(
    bucket,
    capacity=10,
    interval=60,
)

# Use as decorator
@limiter('redis-key')
def call(*args, **kwargs):
    pass

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

pyrate-limiter-0.1.0.tar.gz (3.1 kB view hashes)

Uploaded Source

Built Distribution

pyrate_limiter-0.1.0-py3-none-any.whl (4.2 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