class_docstr: This is like :mod:`pexpect.fdpexpect` but uses the cross-platform python socket api,
  rather than the unix-specific file descriptor api. Thus, it works with
  remote connections on both unix and windows.
class_docstr_tok: ["This","is","like",":","mod",":","`","pexpect.fdpexpect","`","but","uses","the","cross-platform","python","socket","api",",","rather","than","the","unix-specific","file","descriptor","api",".","Thus",",","it","works","with","remote","connections","on","both","unix","and","windows","."]
docstr: Read from the file descriptor and return the result as a string.
  
  The read_nonblocking method of :class:`SpawnBase` assumes that a call
  to os.read will not block (timeout parameter is ignored). This is not
  the case for POSIX file-like objects such as sockets and serial ports.
  
  Use :func:`select.select`, timeout is implemented conditionally for
  POSIX systems.
  
  :param int size: Read at most *size* bytes.
  :param int timeout: Wait timeout seconds for file descriptor to be
      ready to read. When -1 (default), use self.timeout. When 0, poll.
  :return: String containing the bytes read
docstr_tok: ["Read","from","the","file","descriptor","and","return","the","result","as","a","string",".","The","read_nonblocking","method","of",":","class",":","`","SpawnBase","`","assumes","that","a","call","to","os.read","will","not","block","(","timeout","parameter","is","ignored",")",".","This","is","not","the","case","for","POSIX","file-like","objects","such","as","sockets","and","serial","ports",".","Use",":","func",":","`","select.select","`",",","timeout","is","implemented","conditionally","for","POSIX","systems",".",":","param","int","size",":","Read","at","most","*","size","*","bytes",".",":","param","int","timeout",":","Wait","timeout","seconds","for","file","descriptor","to","be","ready","to","read",".","When","-1","(","default",")",",","use","self.timeout",".","When","0",",","poll",".",":","return",":","String","containing","the","bytes","read"]
code: def read_nonblocking(self, size=1, timeout=-1):
      """
      Read from the file descriptor and return the result as a string.
  
      The read_nonblocking method of :class:`SpawnBase` assumes that a call
      to os.read will not block (timeout parameter is ignored). This is not
      the case for POSIX file-like objects such as sockets and serial ports.
  
      Use :func:`select.select`, timeout is implemented conditionally for
      POSIX systems.
  
      :param int size: Read at most *size* bytes.
      :param int timeout: Wait timeout seconds for file descriptor to be
          ready to read. When -1 (default), use self.timeout. When 0, poll.
      :return: String containing the bytes read
      """
      if timeout == -1:
          timeout = self.timeout
      try:
          with self._timeout(timeout):
              s = self.socket.recv(size)
              if s == b"":
                  self.flag_eof = True
                  raise EOF("Socket closed")
              return s
      except socket.timeout:
          raise TIMEOUT("Timeout exceeded.")
  
file_path: catboost/contrib/python/pexpect/py3/pexpect/socket_pexpect.py
imports: import socket
  from contextlib import contextmanager
  from .exceptions import TIMEOUT, EOF
  from .spawnbase import SpawnBase
label_desc: Use image node_id 9 for calling the SocketSpawn obj's underlying member method code with example usage: obj.read_nonblocking(size, timeout) and returns: s