How to set Timeout for Django Rest HTTP request

ⅰ亾dé卋堺 提交于 2021-02-08 06:26:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!