code: def _read_chunk_from_socket(socket):
      
      fd = socket.fileno()
      f = Future()
  
      def read_callback():
          get_event_loop().remove_reader(fd)
  
          # Read next chunk.
          try:
              data = socket.recv(1024)
          except OSError as e:
              # On OSX, when we try to create a new window by typing "pymux
              # new-window" in a centain pane, very often we get the following
              # error: "OSError: [Errno 9] Bad file descriptor."
              # This doesn't seem very harmful, and we can just try again.
              logger.warning('Got OSError while reading data from client: %s. '
                             'Trying again.', e)
              f.set_result('')
              return
  
          if data:
              f.set_result(data)
          else:
              f.set_exception(BrokenPipeError)
  
      get_event_loop().add_reader(fd, read_callback)
  
      return f
docs: (coroutine)
      Turn socket reading into coroutine.