code: def stat( self, *args ):
          '''Check process completion and consume pending I/O data'''
          self.pipe.poll()
          if not self.pipe.returncode is None:
              '''cleanup handlers and timeouts'''
              if not self.expiration is None:
                  self.ioloop.remove_timeout(self.expiration)
              for fd, dest in  self.streams:
                  self.ioloop.remove_handler(fd)
              '''schedulle callback (first try to read all pending data)'''
              self.ioloop.add_callback(self.on_finish)
          for fd, dest in  self.streams:
              while True:
                  try:
                      data = os.read(fd, 4096)
                      if len(data) == 0:
                          break
                      print(data.rstrip())
                  except:
                      breaf stat( self, *args ):
          '''Check process completion and consume pending I/O data'''
          self.pipe.poll()
          if not self.pipe.returncode is None:
              '''cleanup handlers and timeouts'''
              if not self.expiration is None:
                  self.ioloop.remove_timeout(self.expiration)
              for fd, dest in  self.streams:
                  self.ioloop.remove_handler(fd)
              '''schedulle callback (first try to read all pending data)'''
              self.ioloop.add_callback(self.on_finish)
          for fd, dest in  self.streams:
              while True:
                  try:
                      data = os.read(fd, 4096)
                      if len(data) == 0:
                          break
                      print(data.rstrip())
                  except:
                      break
docs: Check process completion and consume pending I/O data