title: processing continuous output of a command in python
body: <p>I'm brand new to python, having used perl for years.  A typical thing I do all the time is perl is open a command as a pipe and assign its output to a local variable for processing.  In other words:</p>
  
  <pre><code>"open CMD, "$command|";
  $output=&lt;CMD&gt;;
  </code></pre>
  
  <p>a piece of cake.  I think I can do something similar in python this way:</p>
  
  <pre><code>args=[command, args...]
  process=subprocess.Popen(args, stdout=subprocess.PIPE)
  output=process.communicate()
  </code></pre>
  
  <p>so far so good.  Now for the big question...</p>
  
  <p>If I fire off that command using an ssh on multiple platforms, I can then monitor the descriptors in perl inside a select loop to process the results as they come in.  I did find the python select and poll modules but am not quite sure how to use them.  The documentation says poll would take a file handle, but when I try to pass the variable 'process' above to poll.register() I get an error that it must be an int or have a fileno() method.  Since Popen() used stdout, I tried calling</p>
  
  <pre><code>poll.register(process.stdout)
  </code></pre>
  
  <p>and it no longer throws an error, but instead just hangs.</p>
  
  <p>Any suggestions/pointers of how to make something like this work?</p>