Skip to main content

pyyarl

pyyarl (Yet Another Rate Limiter for Python) is a Python package for rate limiting function calls.

A lot of Python rate limiting packages seem to exist, but many of them do not have the desired behavior in many use cases. For example, many clear tasks only when the period has elapsed, rather than using a sliding window, or they may mark a task as done prior to running the function rather than after.

pyyarl uses a sliding window of completion times to enforce the rate limit, and is simple to use. pyyarl currently supports single and multithreaded execution.

Table of Contents

Quickstart

For example, the default Google Docs read request quota might be 300 requests per minute:

from pyyarl import rated_limited

@rate_limited(max_calls=300, period_s=60)
def make_read_request(file_id):
    ...  # some request to the Google Docs API


for file_id in file_ids:
    res = make_read_request(file_id)

Having multiple functions limited together

Sometimes, you want to limit multiple functions together such that their calls count towards the same rate.

from pyyarl import RateLimiter

rate_limiter = RateLimiter(max_calls=300, period_s=60)

@rate_limiter
def make_read_request_one(file_id) -> bool:
    ...  # some request to the Google Docs API


@rate_limiter
def make_read_request_two(file_id):
    ...  # some other request to the Google Docs API


for file_id in file_ids:
    if make_read_request_one(file_id):
        make_read_request_two(file_id)

Metadata

Release files for pyyarl 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyyarl 1.0.0
File Size Uploaded
pyyarl-1.0.0.tar.gz 3.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyyarl 1.0.0
File Interpreter ABI Platform
pyyarl-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.9 kB

Release files / pyyarl-1.0.0.tar.gz

Download URL pyyarl-1.0.0.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
7a82b56b0eb4728d0ff2ed90bbe77fae83d8a643ff5325f5cce40a46209f3018
BLAKE2b-256 checksum
How to use checksums
7ef1e54de90295316dbfb4fc9b9eb4ea113e9bf81a782f11cfaf9eb572762f63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.7.14

Release files / pyyarl-1.0.0-py3-none-any.whl

Download URL pyyarl-1.0.0-py3-none-any.whl
Size 4.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9a4f35c0c3951b6f4fca21529b1e60d5656277e891f70df34614e41e703b9a34
BLAKE2b-256 checksum
How to use checksums
6de422af32a9bf9f13812207f7b6281784d760cf54d759e96fd458566eb9467c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.7.14

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page