[Zope] Hang while waiting for external process

Dieter Maurer dieter@handshake.de
Fri, 16 Nov 2001 18:25:44 +0100


Paul Winkler writes:
 > I'm using zope 2.4.3 on linux (redhat 7 with kernel 2.4.14), playing
 > around with the Photo product (nice one!). I've had a few zope
 > freezes, and finally found a pattern: Occasionally, if using
 > ImageMagick to do the rendering for Photo, convert will fail to
 > complete and Zope will then become completely unresponsive. Browser
 > requests do nothing.
 > 
 > This is weird. I can understand how one of the Zope threads might get
 > stuck waiting for the never-ending external process; but why should
 > Zope become completely unresponsive? Shouldn't the other threads keep
 > responding?
They should (and usually do).
Maybe a problem in Python: forgets to release the Global Interpreter Lock
for the system call you use to start your process....

 > And is there a way to set a timeout for an external process, such that
 > zope can recover if it fails to return for too long?
If you use "os.system", then I fear there is no safe way.
For "os.popen" (or variants thereof), you might be able to use
"select" (with a timeout) to check whether the partner closed
the file descriptor. If so, you abandon the process (without
closing the file, neither explicitly nor implicitly!, i.e. must
go into a global variable, preferably a list.). Of course,
you will leak file descriptors in this case.



Dieter