I have got a setup with Apache + mod_wsgi running django code, and Let me give a layer of protection just in case a non-terminating view slips in. Something which kills-off a demands exceeding, say, thirty seconds could be ideal.
For testing I have just put a
time.sleep(60) inside a view.
I have attempted the
TimeOut 30 establishing Apache, however i get curl coming back after a minute.
I see mod_wsgi itself offers three different time-out values, but not one of them appear to use to some lengthy-running request.
It is possible to standard bit of Django middleware with this or it is possible to knob I am missing on Apache or mod_wsgi?
It's really very hard to terminate just one Python request thread inside a multithread application. The very best you should do is come to a decision to shutdown the entire process and restart it. Because this kind of action will disrupt concurrent demands, you'd consequently really should restrict you to ultimately just one threaded configuration.
Even so the support in mod_wsgi 3.X is not well suited for this. There's lack of exercise-timeout for daemon mode, however it really causes process to become restarted in 2 situations. The very first is when you will find no demands whatsoever and process is idle. The second reason is when all request threads have blocked and timeout expires.
In mod_wsgi 4.X (in repository trunk at this time around), the 2 concepts happen to be separated and today lack of exercise-timeout only is applicable to totally idle process without any concurrent demands. A brand new blocked-timeout continues to be put into individually specific a timeout when ever whole process is blocked. It is primarily the latter one you should use.
If you wish to find out more about the brand new option, you will have to go to the mod_wsgi subscriber list to discusss it.