How can I configure Apache2/mod_python/Django to abort request processing after N seconds?
I recently spent a long while debugging something that turned out to be an infinite loop bug in my own code. Since I can't guarantee I'll never make that sort of mistake again, how can I conf开发者_StackOverflow社区igure my web server to terminate any apache2 subprocess that remains waiting for my python app to return a response for over N seconds?
In this case, I didn't even notice the bug until the site started feeling slow, at which point one apache2 process had been running inside an infinite loop for hours. If there were a timeout (even a long one, like 10min) that could have caught this and emailed me, I'd have known about the problem sooner, and it wouldn't have impacted site performance for as many users.
Googling, I've found some suggestions of similar things in a mod_wsgi configuration, but if there's a way to do this under my current setup I'd prefer that. Thanks!
The short answer is no, there is no builtin ability within mod_python to have timeouts on individual requests.
Hmmm.
I wonder if you can use mod_cgi to run your Python script for development. And then go back to mod_python for deployment.
Then you can use the Apache core TimeOut directive to limit how long Apache waits for the mod_cgi response. N.B. Apache 2.2 that is, this extension to the TimeOut directive only came with the 2.2 release.
HTH
精彩评论