Author amicitas
Recipients amicitas
Date 2011-03-10.05:04:27
SpamBayes Score 1.07356e-11
Marked as misclassified No
Message-id <>
I am trying to get the output from an external program into python using `subprocess.Popen` and ``.   For some reason though is at times telling me that stdout is not ready to read, even when it is (reading from it works).   

This problem exists in python 3.1 & 3.2 but not in python 2.7.

For my particular application I am connecting to external program via ssh.  I would not expect that the ssh connection would be an issue.

The program that I am calling produces some output and eventually asks for user input.  In the example below I only get a portion of the output, then at some point tells me that read is not available.  If I try to read anyway I can keep getting more output.  As soon as I press a key (passing something to stdin), tells me that I can read again and I get the rest of the output.   

Any ideas?

    def wrapExternal(host=None):

       command = ["ssh", "-t", host, "some_program"]

       child = subprocess.Popen(command
       out = ''
       while True:
          r, w, x =[child.stdout], [], [], 1.0)
          if child.poll() is not None:
          if r:
             out =
             print(out.decode(), end='')
       return child.returncode
Date User Action Args
2011-03-10 05:04:28amicitassetrecipients: + amicitas
2011-03-10 05:04:28amicitassetmessageid: <>
2011-03-10 05:04:27amicitaslinkissue11459 messages
2011-03-10 05:04:27amicitascreate