Sovled: [Zope] popen hangs on W2K

Thomas Guettler zopestoller@thomas-guettler.de
Mon, 11 Mar 2002 08:51:41 +0100


Thomas Guettler wrote:

> Hi!
>
> popen3() of the python (2.1.2) which comes with zope hangs on W2K:
>
> (stdin, stdout, stderr)=popen3('wvWare -x wvware.xml foo.doc')
> text=stdout.read()
>
> --> read never ends.
>
I found the problem. It is a race condition which might result in a 
deadlock. It only happens
sometimes, so it is something programmers hate.

(stdin, stdout, stderr)=popen3('foo_command')
text=stdout.read()

Imagine foo_command writes a lot to stderr. After some bytes the buffer 
is full. foo_commands blocks while
writing to stderr. The application blocks while reading from stdout. 
---> Dead lock.

One solution would be to write stderr to a file and only read from stdout.

An other explanation:

http://mail.python.org/pipermail/python-dev/2000-September/009460.html

This neither zope nor python specific.

thomas