Oliver Bock wrote:
> My system allows users to write their own python code fragments for some 
> tasks.  Unfortunately the users sometimes write infinite loops, which 
> gradually lock up threads until none remain.  A few minutes later a 
> monitor notices that the system is unresponsive and kills and restarts 
> AppServer.  There must be a better way.
> 
> 1. Can I find out how long each busy thread has been working on its 
> current request?

It's been a while since I've been in that code (ThreadedAppServer) but 
no, I don't believe there's a way to detect wedged threads.  That would 
be a nice feature.

> 2. Can I kill threads without irritating w4py?

Back to basics: no, you can't kill threads in Python.  You can only kill 
the entire process, and even then you have to kill -9 it if a thread is 
truly wedged.

If you have tasks you really expect to sometimes wedge, you need to run 
them in a subprocess that is monitored.  Unfortunately this is not that 
easy.  But at least it *can* be done, the thread monitoring can't be done.

Another perhaps more conservative option is to monitor for wedged 
threads, and then self-destruct the entire process when that happens. 
Using the reloader or something like supervisor 
(http://www.plope.com/software/supervisor) the process can come back up 
after being taken down.


-- 
Ian Bicking  |  [EMAIL PROTECTED]  |  http://blog.ianbicking.org


_______________________________________________
Webware-discuss mailing list
Webware-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to