[mod_python] execution time limit

Graham Dumpleton grahamd at dscpl.com.au
Tue Jan 9 15:52:49 EST 2007


Gustavo Henrique Cervi wrote ..
> Hi.
> 
> How can I to limit the execution time for an python script?
> Something like max_execution_time on PHP..

Are you talking a CGI script written in Python or a Python handler running
under mod_python?

Either way you would have to program such ability within the script. Ie., if
the script is performing some sort of calculation, it would need to
occasionally check itself how long it has been going and abort if need be. If
you are communicating with other processes, rather than block you are going to
have to use some sort of mechanism which will allow you to timeout an
operation. Database systems don't usually allow this though. Depending on the
circumstances, you may be able to farm the operation off to a distinct thread
with the parent waiting for the thread to complete, but if it doesn't complete
in time for it to send back failure. The separate thread will still continue
until it completes though as not easy to kill threads.

You might explain more about what you are actually trying to do.

Graham


More information about the Mod_python mailing list