popen2.popen2,3,4 from Python 2.0 on NT 4.0 SP5

Mark Tompkins mdtompkins at home.com
Wed Oct 25 19:07:30 EDT 2000


Hi,

I want to write a platform agnostice database installation utility in
Python for Oracle on Winnt and *NIX.  I'm using the version of Idle that
comes with Python 2.0.

I was doing some testing, and have hit the wall right off the bat.  When
I use popen2.popenX('cmd') to call the sqlplus utility, reading stdout
of the cmd appears to hang when the read is past the last character in
the buffer, or when there is no data (as what happens, if there is an
error)????

import popen2

# it doesn't matter which popen function? that I use, only difference is
how failure occurs
# (whether stdout and stderr are mixed or not)

x=popen2.popen3('sqlplus pf/pf at dds230pf3 @rowcount.sql')
y=x[0].readline()

# if rowcount.sql doesn't exist, hang occurs here immediately

So:

x[0] is the stdout of the shelled command, which is where I read from
for input to my program -> file in read mode.

1.  Why does it hang?  This seems like a bug.  It should return with
some known response, or nothing.
2.  Is there a way to find out how many characters are left in the
stdout/stderr buffers?
3.  This test is for winnt.  Is unix different, and should I use
win32all to workaround (I would rather not, if possible)?
4.  Should I use threading, and use another thread to see when the
readline() fails to return (messy)?
5.  Is this a shelled process state problem, or a buffer state problem?
6.  Does this problem throw any exception?

thx in advance

Mark




More information about the Python-list mailing list