Skip to main content

asyncio rate limiter, a leaky bucket implementation

Project description

aiolimiter

Azure Pipelines status for master branch codecov.io status for master 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.7 or newer.

Requirements

  • Python >= 3.7

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 poetry to manage dependencies, testing and releases. Make sure you have installed that tool, then run the following command to get set up:

poetry install --with docs && poetry run doit devsetup

Apart from using poetry run doit devsetup, you can either use poetry shell to enter a shell environment with a virtualenv set up for you, or use poetry run ... to run commands within the virtualenv.

Tests are run with pytest and tox. Releases are made with poetry build and poetry publish. Code quality is maintained with flake8, black and mypy, and pre-commit runs quick checks to maintain the standards set.

A series of doit tasks are defined; run poetry run doit list (or doit list with poetry shell activated) to list them. The default action is to run a full linting, testing and building run. It is recommended you run this before creating a pull request.

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

aiolimiter-1.1.0.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

aiolimiter-1.1.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file aiolimiter-1.1.0.tar.gz.

File metadata

  • Download URL: aiolimiter-1.1.0.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for aiolimiter-1.1.0.tar.gz
Algorithm Hash digest
SHA256 461cf02f82a29347340d031626c92853645c099cb5ff85577b831a7bd21132b5
MD5 f207d912c23a351d76adf7f3643734a0
BLAKE2b-256 df626de944a6839a68f7d69e552e26d12234d9c556472e4c277a3a563013640a

See more details on using hashes here.

File details

Details for the file aiolimiter-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: aiolimiter-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for aiolimiter-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0b4997961fc58b8df40279e739f9cf0d3e255e63e9a44f64df567a8c17241e24
MD5 a5dfaac6ceccd57e4c32e73fe567db60
BLAKE2b-256 60694b7dea755fafa10b248928da836a2cc8b5cff0762f363234e24218040f8e

See more details on using hashes here.

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