[Python-bugs-list] [ python-Bugs-527783 ] popen3 hangs on windows
noreply@sourceforge.net
noreply@sourceforge.net
Sat, 09 Mar 2002 10:14:49 -0800
Bugs item #527783, was opened at 2002-03-09 13:13
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=527783&group_id=5470
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Chris Withers (fresh)
Assigned to: Nobody/Anonymous (nobody)
Summary: popen3 hangs on windows
Initial Comment:
The following hangs on windows:
(i,o,e)=popen('python test.py')
result=o.read()+e.read()
...where test.py is the test.py of a Zope 3 CVS
checkout. I suspected a Zope 3 problem, but Thomas
Guettler also expereinced this in a different context:
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()
Then again, having seen bug #481896, I'm not sure this
is confined to windows.
Any ideas?
----------------------------------------------------------------------
>Comment By: Chris Withers (fresh)
Date: 2002-03-09 18:14
Message:
Logged In: YES
user_id=24723
So what should I use instead of e.read() ad o.read()
In fact, any chance of a replacement line for:
result=o.read()+e.read()
? ;-)
cheers,
Chris
----------------------------------------------------------------------
Comment By: Darrell Gallion (dgallion)
Date: 2002-03-09 18:11
Message:
Logged In: YES
user_id=68151
Don't use e.read()
This will try to read the entire file. Which doesn't
make sense with a stream. Although I think this works with sockets?
I'll look at a select solution.
Not sure how to know how many bytes to
read after the select breaks out.
----------------------------------------------------------------------
Comment By: Darrell Gallion (dgallion)
Date: 2002-03-09 14:51
Message:
Logged In: YES
user_id=68151
This cuased the problem on Linux.
import os, re
files="""
file
errXX.py
<<<<<<<<<<<<<
import sys
while 1:
print >>sys.stderr,
'x'
<<<<<<<<<<<<<
file runXX.py
<<<<<<<<<<<<<
import
os
(i,o,e)=os.popen3("python errXX.py")
print
e.read()
<<<<<<<<<<<<<
cmd python
runXX.py
<<<<<<<<<<<<<
"""
files=re.split("<<<<<+",files)
for
x in range(0,len(files), 2):
cmd=files[x].split()
body=files[x+1]
if cmd[0]=='file':
open(cmd[1],'w').write(body)
elif cmd[0]=='cmd':
os.system('
'.join(cmd[1:])+body)
else:
assert(0)
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=527783&group_id=5470