Django long-term query autocompletion

I have a setup with Apache + mod_wsgi that runs django code, and I would like to add a layer of protection in case the view doesn't end without end. Something that kills requests in excess of, say, 30 seconds would be ideal.

For testing, I just put time.sleep(60)in a view.

I tried setting TimeOut 30in Apache, but after 60 seconds I still get curl.

I see that mod_wsgi itself offers three different timeout values, but none of them seem to apply to a long-term request.

Is there a standard piece of Django middleware for this, or is there a pen that I miss in Apache or mod_wsgi?

+5
source share
1 answer

It is actually very difficult to terminate a single Python request stream in a multi-threaded application. The best you can do is decide to shut down the whole process and restart it. Since this action violates concurrent requests, as a result, you really need to limit yourself to a single configuration with multiple threads.

Even then, support in mod_wsgi 3.X is not ideal for this. There is an inactive timeout for daemon mode, but it actually causes the process to restart in two situations. Firstly, when there are no requests, the process is idle. Secondly, when all request flows are blocked and time out.

mod_wsgi 4.X( ) , . - -, . .

, mod_wsgi, .

+6

All Articles