Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

call-throttle

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

call-throttle

A decorator used to throttle calls of regular functions and asyncio coroutines.

  • 0.4.0
  • PyPI
  • Socket score

Maintainers
1

call-throttle

python version downloads format

This package provides decorators which can be used to throttle calls of regular Python functions and asyncio coroutines.

Install

Use pip package installer for Python:

python -m pip install --upgrade call-throttle

Make sure you have Python 3.7 or later installed.

Usage

Here is a basic example for how to use the throttle decorator with functions and coroutines:

import time
import asyncio
from datetime import timedelta

from call_throttle import throttle


@throttle(calls=1, period=timedelta(seconds=1))
def func():
    time.sleep(1)


@throttle(calls=1, period=timedelta(seconds=2))
async def coro():
    await asyncio.sleep(1)

If passing raise_on_throttle=True to @throttle(...), then a call_throttle.ThrottleException is raised when a decorated function or coroutine is called more times than the defined calls limit within the specified time period.

License

This is a free software licensed under the terms of the MIT License.

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc