Skip to main content

limited 🚀

limited is your go-to Python rate limiting package, designed for advanced and efficient performance. It seamlessly supports both synchronous programs, using threads through SyncLimiter, and asynchronous programs, utilizing asyncio through AsyncLimiter.

Examples 📝

Getting started with limited is effortless! For regular, synchronous functions declared with def, use SyncLimiter:

from limited import SyncLimiter

@SyncLimiter(limit=3, every=5)
def job():
    pass

For asynchronous functions declared with async def, opt for AsyncLimiter:

from limited import AsyncLimiter

@AsyncLimiter(limit=3, every=5)
async def async_job():
    pass

Share Limits 👨‍👦‍👦

Take it up a notch by creating a limiter instance and share it across multiple functions. This allows you to enforce the same constraints on multiple functions simultaneously. In the example below, both first_job and second_job are limited to 3 calls every 5 seconds, collectively.

from limited import SyncLimiter

my_limiter = SyncLimiter(limit=3, every=5)

@my_sync_limiter
def first_job():
    pass

@my_sync_limiter
def second_job():
    pass

For asynchronous functions, employ AsyncLimiter in a similar fashion.

Stack Limits 📚

Stack limits on a single function to satisfy multiple constraints simultaneously. In the following example, both limiting constrained are enforces separately.

from limited import SyncLimiter

my_first_limiter = SyncLimiter(limit=3, every=5)
my_second_limiter = SyncLimiter(limit=1, every=1)

@my_first_limiter
@my_second_limiter
def my_job():
    pass

Combining sharing limits with multiple functions, and stacking multiple limits to the same functions, allows for complex limiting logic.

limited offers the flexibility you need to create complex rate limiting logic effortlessly. Fine-tune your applications, experiment, and let your projects soar to new heights! 🚀✨

Metadata

Release files for limited 0.1.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 limited 0.1.0
File Size Uploaded
limited-0.1.0.tar.gz 15.6 kB Details

Built distribution (wheel)

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

Total release size: 32.4 kB

Release files / limited-0.1.0.tar.gz

Download URL limited-0.1.0.tar.gz
Size 15.6 kB
Tags Source
SHA-256 checksum
How to use checksums
443668d70fdbdcc791b91962b405018d817198d981d5ad05bd8e44152c14493a
BLAKE2b-256 checksum
How to use checksums
9e8f7dc34806595f04ff00a9d5369d14cbd63f7115aefc2c43c01a750146c73f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / limited-0.1.0-py3-none-any.whl

Download URL limited-0.1.0-py3-none-any.whl
Size 16.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b7dbd5741089943fe1cf470efdb220cda1404e3988b51c0b95cf216fff47b33a
BLAKE2b-256 checksum
How to use checksums
fd96a2d77cd08d98fb029ad6b824b121a5899d23102b1b50d0de23596e4aaade
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release history Release notifications | RSS feed

This release

0.1.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