[Zope-Coders] Re: [Zope] popen hangs on W2K

Tim Peters tim@zope.com
Sat, 9 Mar 2002 14:02:57 -0500


[Chris Withers]
> I've changed the list since I've mentioned this just recently...
>
> 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.
>>
>> It works if wvware produces few output, but with larger files it hangs
>> (0% CPU usage).

> This is exactly what I was experiencing with the Zope 3 tests as well.
>
> It's not limited to Win2K, I've had the same issue with Windows
> NT4 and Windows 2K, and it's not just python 2.1.2, I've had the same
> with 2.1.1 and 2.2.
>
> I really don't know how to begin sorting this out, hopefully
> someone on this list will pipe up, at least with the right place to
> ask these questions...

I don't hold out much hope.  The popen family comes from Unix, and all
attempts to implement it on Windows seem to fail sooner or later;
Microsoft's own implementation of plain popen() is riddled with failure
modes.

Mark Hammond and Bill Tutt (from Microsoft) contributed Python's popen code.
They did the best they could, and no attempt to improve it has actually
helped.  In the end, failing cases bash against a dozen layers of backward
compatibility hacks in the MS internals, and at that point-- since you don't
have the source code --you're reduced to reverse-engineering machine-code
dumps.  It's always time-consuming and hasn't yet borne fruit, so I won't
look at another of these unless I'm told to.

OTOH, maybe *this* one is shallow <wink>.

For my own use, I capture stdout and stderr on Windows via the TCAP program,
available here:

    ftp://ftp.simtel.net/pub/simtelnet/msdos/sysutl/tcap31.zip

That uses assembler to hook the low-level "console I/O" interrupts inherited
from DOS, so avoids the high-level layers of MS system software where things
usually flake out.  It works well.  OTOH, it's *only* good for capturing
output sent to a console window.  Hmm!  It occurs to me I never tried it on
Win2K, just Win9x.  Caveat programmer.