Bug? - win32pipe.popen2 is moody under W98

Eric Johnson ejohnson at netcom.com
Mon Nov 15 22:51:27 EST 1999


I'm working on a multi-threaded make engine under Python.  In so
doing, I'm desperately trying to get a popen like facility running 
under Win98 in Python.  I've got Mark Hammond's win32 extensions
(build 127 to be exact), and I'm still striking out.

The following sample code spins off a couple of threads.  Each thread
makes a popen2 call and displays the results.  Ideally, each popen2
call should be capable of being executed in tandem with the rest.


import threading
import thread
import win32pipe

def doit():
  print "here\n";
  a=win32pipe.popen2("dir")
  s=a[1].readline()
  while(s):
    print s
    s=a[1].readline()
  print "Done\n"

for n in range(4):
  a1=threading.Thread(target=doit)
  a1.start()


This and its variant that uses os.popen directly works just fine under
NT 4.0.  But under W98, it gets all hung up on itself quite quickly.
Repeated investigation and experimentation shows that the hang point
appears to be on simulataneous calls to .readline() while another
thread is invoking popen.

Can anyone say either way whether this can be expected to work under
W98?

-Eric Johnson







More information about the Python-list mailing list