Request limiter contains a decorator to limit the rate of http request
Project description
Request Limiter
Request limiter contains a decorator to limit the rate of http request
Free software: MIT license
Documentation: https://request-limiter.readthedocs.io.
Features
A decorator to limit django http request
A strategy to limit request per interval using requester IP
Get started
Installation:
$ pip install request_limiter
Limit request to django view using a decorator:
from request_limiter import request_limiter, LimitedIntervalStrategy, django_request_limiter
@django_request_limiter
@request_limiter(strategy=LimitedIntervalStrategy(requests=10, interval=60)) # 10 request per minute
def myview(request):
# ...
Limit the number of request to function or part of it:
from request_limiter import request_limiter, LimitedIntervalStrategy, LimitException
@request_limiter(strategy=LimitedIntervalStrategy(requests=1, interval=60)) # 1 request per minute
def awesome_work(param):
# ...
awesome_work("test")
try:
awesome_work("limited") # raises LimitException
except LimitException:
# .. handle limit exception
limiter = LimitedIntervalStrategy(requests=1, interval=60)) # 1 request per minute
def another_work(param):
if not limiter.allow():
return False
# ...
return True
another_work("job1") # returns True
another_work("job2") # returns False
Credits
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
History
0.1.1 (2020-01-14)
First release on PyPI.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file request_limiter-0.1.1.tar.gz.
File metadata
- Download URL: request_limiter-0.1.1.tar.gz
- Upload date:
- Size: 17.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/3.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d239739026fb7ee0b606d7f9d8b9638eda54bef5dde29781cd81c43a51afb74
|
|
| MD5 |
d1cc14ae601e3736027f2d7ebb46ed14
|
|
| BLAKE2b-256 |
f1e64b29aaf41ad8e2ded39a3caaac3ad370c1b4f3567f6feefc182b8d220ea8
|
File details
Details for the file request_limiter-0.1.1-py2.py3-none-any.whl.
File metadata
- Download URL: request_limiter-0.1.1-py2.py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/3.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6aba04280d0695ac66e1020afc52226dda7e53a61d9abc08db0fb631a51c59cb
|
|
| MD5 |
287a8c6ac6bfb454d3c60171e2c5e5fc
|
|
| BLAKE2b-256 |
48d86361e53f2cb7159b1a2c2506cc6805a2a3244724b58165804b7880535ce5
|