title: stopping a python thread waiting for popen?
body: <p>I have a thread which calls <code>Popen</code> to get a string back from a command line utility.  This command line function does not return until some very, very laggy network data arrives.  Sometimes it could take minutes, other times under a second.</p>
  
  <p>If the user wants, they can can cancel waiting for this data.  In this case, what is the right way to stop the thread?</p>
  
  <pre><code>class CommThread( threading.Thread ):
  
      def __init__(self):
          self.stdout = None
          self.stderr = None
          self.command = None
          threading.Thread.__init__(self)
  
      def run(self):
          if self.command is not None:
              p = Popen( self.command.split(), shell=False, stdout=PIPE, stderr=PIPE)
              self.stdout, self.stderr = p.communicate()
  </code></pre>