mjpieters/aiolimiter

An efficient implementation of a rate limiter for asyncio.

Python

787

745 commits

updated Oct 12, 2026

See the code

README

aiolimiter

GitHub Actions status for default branch codecov.io status for default branch Latest PyPI package version Latest Read The Docs

Introduction

An efficient implementation of a rate limiter for asyncio.

This project implements the Leaky bucket algorithm, giving you precise control over the rate a code section can be entered:

from aiolimiter import AsyncLimiter

# allow for 100 concurrent entries within a 30 second window
rate_limit = AsyncLimiter(100, 30)


async def some_coroutine():
    async with rate_limit:
        # this section is *at most* going to entered 100 times
        # in a 30 second period.
        await do_something()

It was first developed as an answer on Stack Overflow.

Documentation

https://aiolimiter.readthedocs.io

Installation

$ pip install aiolimiter

The library requires Python 3.10 or newer.

Requirements

  • Python >= 3.10

License

aiolimiter is offered under the MIT license.

Source code

The project is hosted on GitHub.

Please file an issue in the bug tracker if you have found a bug or have some suggestions to improve the library.

Developer setup

This project uses uv to manage dependencies, testing and releases. Make sure you have installed that tool, then run the following command to get set up:

uv sync

Tests are run with pytest and tox. Releases are made managed by a GitHub Actions workflow. Code quality is maintained with ruff and pyright, and prek runs quick checks to maintain the standards set.

A Taskfile is provided that defines specific tasks such as linting, formatting or previewing the documentation:

$ task --list
task: Available tasks for this project:
* default:                               Default task, runs linters and tests
* dev:format:                            Runs formatters                           (aliases: format)
* dev:install-prek:                      Install prek into local git checkout      (aliases: dev:install-precommit)
* dev:lint:                              Runs linters                              (aliases: lint)
* dev:lint:code:                         Lint the source code
* dev:lint:renovate:                     Lint the Renovate configuration file
* dev:test:                              Run tests                               (aliases: test)
* dev:tox:                               Run tests with tox                      (aliases: tox)
* dev:uv-lock:                           Updates the uv lock file                (aliases: lock)
* dist:build:                            Build the distribution packages         (aliases: dist)
* dist:clean:                            Remove built distribution packages      (aliases: clean)
* dist:publish:                          Publish package to PyPI                 (aliases: publish)
* docs:build:                            Build project documentation             (aliases: docs)
* docs:checks:                           Run all documentation checks
* docs:checks:spelling:                  Check documentation spelling.
* docs:checks:towncrier:                 Check changelog towncrier output()
* docs:checks:towncrier_fragments:       Check changelog towncrier fragments
* docs:clean:                            Clean the documentation build directory
* docs:serve:                            Live preview server for project documentation      (aliases: preview)
asyncio
leaky-bucket
rate-limiting

mjpieters/aiolimiter

An efficient implementation of a rate limiter for asyncio.

Python

787

745 commits

updated Oct 12, 2026

See the code

README

aiolimiter

GitHub Actions status for default branch codecov.io status for default branch Latest PyPI package version Latest Read The Docs

Introduction

An efficient implementation of a rate limiter for asyncio.

This project implements the Leaky bucket algorithm, giving you precise control over the rate a code section can be entered:

from aiolimiter import AsyncLimiter

# allow for 100 concurrent entries within a 30 second window
rate_limit = AsyncLimiter(100, 30)


async def some_coroutine():
    async with rate_limit:
        # this section is *at most* going to entered 100 times
        # in a 30 second period.
        await do_something()

It was first developed as an answer on Stack Overflow.

Documentation

https://aiolimiter.readthedocs.io

Installation

$ pip install aiolimiter

The library requires Python 3.10 or newer.

Requirements

  • Python >= 3.10

License

aiolimiter is offered under the MIT license.

Source code

The project is hosted on GitHub.

Please file an issue in the bug tracker if you have found a bug or have some suggestions to improve the library.

Developer setup

This project uses uv to manage dependencies, testing and releases. Make sure you have installed that tool, then run the following command to get set up:

uv sync

Tests are run with pytest and tox. Releases are made managed by a GitHub Actions workflow. Code quality is maintained with ruff and pyright, and prek runs quick checks to maintain the standards set.

A Taskfile is provided that defines specific tasks such as linting, formatting or previewing the documentation:

$ task --list
task: Available tasks for this project:
* default:                               Default task, runs linters and tests
* dev:format:                            Runs formatters                           (aliases: format)
* dev:install-prek:                      Install prek into local git checkout      (aliases: dev:install-precommit)
* dev:lint:                              Runs linters                              (aliases: lint)
* dev:lint:code:                         Lint the source code
* dev:lint:renovate:                     Lint the Renovate configuration file
* dev:test:                              Run tests                               (aliases: test)
* dev:tox:                               Run tests with tox                      (aliases: tox)
* dev:uv-lock:                           Updates the uv lock file                (aliases: lock)
* dist:build:                            Build the distribution packages         (aliases: dist)
* dist:clean:                            Remove built distribution packages      (aliases: clean)
* dist:publish:                          Publish package to PyPI                 (aliases: publish)
* docs:build:                            Build project documentation             (aliases: docs)
* docs:checks:                           Run all documentation checks
* docs:checks:spelling:                  Check documentation spelling.
* docs:checks:towncrier:                 Check changelog towncrier output()
* docs:checks:towncrier_fragments:       Check changelog towncrier fragments
* docs:clean:                            Clean the documentation build directory
* docs:serve:                            Live preview server for project documentation      (aliases: preview)
asyncio
leaky-bucket
rate-limiting

Project health

Overall

7.2/10

Maintained

10/10
OpenSSF Scorecard

Latest release

1.3.0 · Sep 7, 2026

Releases this year

1

Significant stargazers

Daniel van Strien

392 followers · starred Nov 2025

Frost Ming

1,718 followers · starred Jan 2024

Zilin Zhu

2,218 followers · starred Sep 2025

Zhiwei He

196 followers · starred Oct 2025