问题
I am using Python 3.5, Django 1.9.5 and Django Rest Framework 3.3.3. I have only few POST apis in my server.
How can I set Timeout for each rest http request that if the execution for a request takes more then 3 minutes than it should return timeout in response and should stop execution of that request.
Thanks :)
回答1:
I think you will need to set this at the proxy/web server level.
With nginx you can use proxy_read_timeout:
proxy_read_timeout 180s;
Or you could set it at the application server level. Gunicorn has a timeout setting.
来源:https://stackoverflow.com/questions/42155616/how-to-set-timeout-for-django-rest-http-request