sobotklp / django-throttle-requests Goto Github PK
View Code? Open in Web Editor NEWa framework for implementing application-level request throttling for Django
License: MIT License
a framework for implementing application-level request throttling for Django
License: MIT License
Instead of adding throttle to my python path, would adding throttle to INSTALLED APPS work too?
Try as I might, I can't seem to wrap my head around what this config value is exactly and the docs don't explain it (or the others for that matter, but I've managed to figure those out I think). Any chance of getting a description?
@sobotklp I'm testing the following:
THROTTLE_ZONES = {
'default': {
'VARY':'throttle.zones.RemoteIP',
'NUM_BUCKETS':2, # Number of buckets worth of history to keep. Must be at least 2
'BUCKET_INTERVAL':10, # Period of time to enforce limits.
'BUCKET_CAPACITY':2, # Maximum number of requests allowed within BUCKET_INTERVAL
},
}
The above allows me 2 requests in every 5 seconds instead of 10. Have you seen this behavior too?
doesn't seem to be in the pip list of packages.
How does the decorator work on Django's class base views?
Not just a 403 page, need some where to add a descrption text config to show on the 403 page.
When we reached to limit. your app tries to show a 403 forbidden page.
django 3.2
python 3.8
I'm using default configs. but i got error below:
Forbidden (Permission denied): /books/hello/
Traceback (most recent call last):
File "C:\Users\linux10\Desktop\my_all_envs\azimzadeh_env1\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
response = get_response(request)
File "C:\Users\linux10\Desktop\my_all_envs\azimzadeh_env1\lib\site-packages\django\core\handlers\base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\linux10\Desktop\my_all_envs\azimzadeh_env1\lib\site-packages\django\views\decorators\csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "C:\Users\linux10\Desktop\my_all_envs\azimzadeh_env1\lib\site-packages\django\views\generic\base.py", line 70, in view
return self.dispatch(request, *args, **kwargs)
File "C:\Users\linux10\Desktop\my_all_envs\azimzadeh_env1\lib\site-packages\django\utils\decorators.py", line 43, in _wrapper
return bound_method(*args, **kwargs)
File "C:\Users\linux10\Desktop\my_all_envs\azimzadeh_env1\lib\site-packages\throttle\decorators.py", line 15, in _wrapped_view
response = _throttle_zone.process_view(request, func, args, kwargs)
File "C:\Users\linux10\Desktop\my_all_envs\azimzadeh_env1\lib\site-packages\throttle\zones\__init__.py", line 72, in process_view
raise RateLimitExceeded(self.name)
throttle.exceptions.RateLimitExceeded: default
[16/May/2021 15:54:03] "GET /books/hello/ HTTP/1.1" 403 200
In the archive from pypi the file throttle/zone/__init__.py
at line 65, reads
bucket_num_next = (bucket_num + 1) % 2
where as in github it is:
bucket_num_next = (bucket_num + 1) % self.num_buckets
Of course this leads to unexpected results !!!
Hey,
Could you release the most recent version on pypi, please?
Regards :)
available_attrs
was removed in Django 3.
Thus, this package doesn't work:
File "/home/rain0r/.virtualenvs/urlsh/lib/python3.7/site-packages/throttle/decorators.py", line 2, in <module>
from django.utils.decorators import available_attrs
ImportError: cannot import name 'available_attrs' from 'django.utils.decorators' (/home/rain0r/.virtualenvs/urlsh/lib/python3.7/site-packages/django/utils/decorators.py)
When using the default RemoteIp handler you can catch the following exception:
ip = "100.200.300.400, 101.201.301.401"
With this ip you catch the following exception:
MemcachedKeyCharacterError: Control/space characters not allowed (key=':1:key:100.200.300.400, 101.201.301.401:0')
Hi @sobotklp is there a possibility that we can change the value of BUCKET_INTERVAL for every request. Need to use rate limit based upon the value of an object stored in database?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.