code: def is_done(self):
          
  
          return (not self.wait_for_output or self.eof) and \
                  not (hasattr(self.to_stream, 'needs_write') and self.to_stream.needs_write())
docs: Returns True if the read stream is done (either it's returned EOF or
          the pump doesn't have wait_for_output set), and the write
          side does not have pending bytes to send.