Skip to main content

ratelimit

Project description

ratelimit ########

  1. 安装 ==========

.. code-block:: shell

pip install ratelimit-py3

  1. 示例 ==========
  • 2.1 异步

.. code-block:: python

@AsyncRateLimit(limit=3)
async def add(a, b):
    await asyncio.sleep(0.01)
    return a + b


@AsyncRateLimit(limit=3, uniform_rate=True)
async def sub(a, b):
    await asyncio.sleep(0.2)
    return a - b
  • 2.2 同步

.. code-block:: python

@RateLimit(limit=3)
def add(a, b):
    time.sleep(0.01)
    return a + b


@RateLimit(limit=3, uniform_rate=True)
def sub(a, b):
    time.sleep(0.02)
    return a - b

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

dayu_ratelimit-1.2.5.tar.gz (5.8 kB view hashes)

Uploaded Source

Built Distribution

dayu_ratelimit-1.2.5-py3-none-any.whl (7.0 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