code: def read(socket, n=4096):
      
  
      recoverable_errors = (errno.EINTR, errno.EDEADLK, errno.EWOULDBLOCK)
  
      if six.PY3 and not isinstance(socket, NpipeSocket):
          select.select([socket], [], [])
  
      try:
          if hasattr(socket, 'recv'):
              return socket.recv(n)
          if six.PY3 and isinstance(socket, getattr(pysocket, 'SocketIO')):
              return socket.read(n)
          return os.read(socket.fileno(), n)
      except EnvironmentError as e:
          if e.errno not in recoverable_errors:
              raise
docs: Reads at most n bytes from socket