Skip to content

python decorator that limits the calling rate of a function

License

Notifications You must be signed in to change notification settings

dan-writes-code/limit

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

limit

python decorator that limits the calling rate of a function

Description

https://raw.githubusercontent.com/enricobacis/limit/master/.screenshot/limit.gif

This decorator limits the calling rate of the decorated function. This is useful in conjuction with web API calls, where you often get banned if you perform more calls than the ones specified in the terms of services.

The rate is limit over every, where limit is the number of invocation allowed every every seconds. limit(4, 60) creates a decorator that limits the function calls to 4 per minute. If not specified, every defaults to 1 second.

@limit(4, 60)
def function(...):
    """never invoke this function more than 4 times per minute."""
    ...

Installation

The package has been uploaded to PyPI, so you can install it with pip:

pip install limit

About

python decorator that limits the calling rate of a function

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%