parameters: (self, size=1, timeout=-1)
docstring: This reads at most size characters from the child application. It
          includes a timeout. If the read does not complete within the timeout
          period then a TIMEOUT exception is raised. If the end of file is read
          then an EOF exception will be raised.  If a logfile is specified, a
          copy is written to that log.
  
          If timeout is None then the read may block indefinitely.
          If timeout is -1 then the self.timeout value is used. If timeout is 0
          then the child is polled and if there is no data immediately ready
          then this will raise a TIMEOUT exception.
  
          The timeout refers only to the amount of time to read at least one
          character. This is not affected by the 'size' parameter, so if you call
          read_nonblocking(size=100, timeout=30) and only one character is
          available right away then one character will be returned immediately.
          It will not wait for 30 seconds for another 99 characters to come in.
  
          This is a wrapper around os.read(). It uses select.select() to
          implement the timeout.
docstring_summary: This reads at most size characters from the child application. It
          includes a timeout. If the read does not complete within the timeout
          period then a TIMEOUT exception is raised. If the end of file is read
          then an EOF exception will be raised.  If a logfile is specified, a
          copy is written to that log.
docstring_tokens: This reads at most size characters from the child application . It includes a timeout . If the read does not complete within the timeout period then a TIMEOUT exception is raised . If the end of file is read then an EOF exception will be raised . If a logfile is specified a copy is written to that log .
function: def read_nonblocking(self, size=1, timeout=-1):
          '''This reads at most size characters from the child application. It
          includes a timeout. If the read does not complete within the timeout
          period then a TIMEOUT exception is raised. If the end of file is read
          then an EOF exception will be raised.  If a logfile is specified, a
          copy is written to that log.
  
          If timeout is None then the read may block indefinitely.
          If timeout is -1 then the self.timeout value is used. If timeout is 0
          then the child is polled and if there is no data immediately ready
          then this will raise a TIMEOUT exception.
  
          The timeout refers only to the amount of time to read at least one
          character. This is not affected by the 'size' parameter, so if you call
          read_nonblocking(size=100, timeout=30) and only one character is
          available right away then one character will be returned immediately.
          It will not wait for 30 seconds for another 99 characters to come in.
  
          This is a wrapper around os.read(). It uses select.select() to
          implement the timeout. '''
  
          if self.closed:
              raise ValueError('I/O operation on closed file.')
  
          if timeout == -1:
              timeout = self.timeout
  
          # Note that some systems such as Solaris do not give an EOF when
          # the child dies. In fact, you can still try to read
          # from the child_fd -- it will block forever or until TIMEOUT.
          # For this case, I test isalive() before doing any reading.
          # If isalive() is false, then I pretend that this is the same as EOF.
          if not self.isalive():
              # timeout of 0 means "poll"
              if self.use_poll:
                  r = poll_ignore_interrupts([self.child_fd], timeout)
              else:
                  r, w, e = select_ignore_interrupts([self.child_fd], [], [], 0)
              if not r:
                  self.flag_eof = True
                  raise EOF('End Of File (EOF). Braindead platform.')
          elif self.__irix_hack:
              # Irix takes a long time before it realizes a child was terminated.
              # FIXME So does this mean Irix systems are forced to always have
              # FIXME a 2 second delay when calling read_nonblocking? That sucks.
              if self.use_poll:
                  r = poll_ignore_interrupts([self.child_fd], timeout)
              else:
                  r, w, e = select_ignore_interrupts([self.child_fd], [], [], 2)
              if not r and not self.isalive():
                  self.flag_eof = True
                  raise EOF('End Of File (EOF). Slow platform.')
          if self.use_poll:
              r = poll_ignore_interrupts([self.child_fd], timeout)
          else:
              r, w, e = select_ignore_interrupts(
                  [self.child_fd], [], [], timeout
              )
  
          if not r:
              if not self.isalive():
                  # Some platforms, such as Irix, will claim that their
                  # processes are alive; timeout on the select; and
                  # then finally admit that they are not alive.
                  self.flag_eof = True
                  raise EOF('End of File (EOF). Very slow platform.')
              else:
                  raise TIMEOUT('Timeout exceeded.')
  
          if self.child_fd in r:
              return super(spawn, self).read_nonblocking(size)
  
          raise ExceptionPexpect('Reached an unexpected state.')
function_tokens: def read_nonblocking ( self , size = 1 , timeout = - 1 ) : if self . closed : raise ValueError ( 'I/O operation on closed file.' ) if timeout == - 1 : timeout = self . timeout # Note that some systems such as Solaris do not give an EOF when # the child dies. In fact, you can still try to read # from the child_fd -- it will block forever or until TIMEOUT. # For this case, I test isalive() before doing any reading. # If isalive() is false, then I pretend that this is the same as EOF. if not self . isalive ( ) : # timeout of 0 means "poll" if self . use_poll : r = poll_ignore_interrupts ( [ self . child_fd ] , timeout ) else : r , w , e = select_ignore_interrupts ( [ self . child_fd ] , [ ] , [ ] , 0 ) if not r : self . flag_eof = True raise EOF ( 'End Of File (EOF). Braindead platform.' ) elif self . __irix_hack : # Irix takes a long time before it realizes a child was terminated. # FIXME So does this mean Irix systems are forced to always have # FIXME a 2 second delay when calling read_nonblocking? That sucks. if self . use_poll : r = poll_ignore_interrupts ( [ self . child_fd ] , timeout ) else : r , w , e = select_ignore_interrupts ( [ self . child_fd ] , [ ] , [ ] , 2 ) if not r and not self . isalive ( ) : self . flag_eof = True raise EOF ( 'End Of File (EOF). Slow platform.' ) if self . use_poll : r = poll_ignore_interrupts ( [ self . child_fd ] , timeout ) else : r , w , e = select_ignore_interrupts ( [ self . child_fd ] , [ ] , [ ] , timeout ) if not r : if not self . isalive ( ) : # Some platforms, such as Irix, will claim that their # processes are alive; timeout on the select; and # then finally admit that they are not alive. self . flag_eof = True raise EOF ( 'End of File (EOF). Very slow platform.' ) else : raise TIMEOUT ( 'Timeout exceeded.' ) if self . child_fd in r : return super ( spawn , self ) . read_nonblocking ( size ) raise ExceptionPexpect ( 'Reached an unexpected state.' )