code: def read_all(self, n, check_rekey=False):
          
          out = ''
          # handle over-reading from reading the banner line
          if len(self.__remainder) > 0:
              out = self.__remainder[:n]
              self.__remainder = self.__remainder[n:]
              n -= len(out)
          if PY22:
              return self._py22_read_all(n, out)
          while n > 0:
              got_timeout = False
              try:
                  x = self.__socket.recv(n)
                  if len(x) == 0:
                      raise EOFError()
                  out += x
                  n -= len(x)
              except socket.timeout:
                  got_timeout = True
              except socket.error, e:
                  # on Linux, sometimes instead of socket.timeout, we get
                  # EAGAIN.  this is a bug in recent (> 2.6.9) kernels but
                  # we need to work around it.
                  if (type(e.args) is tuple) and (len(e.args) > 0) and (e.args[0] == errno.EAGAIN):
                      got_timeout = True
                  elif (type(e.args) is tuple) and (len(e.args) > 0) and (e.args[0] == errno.EINTR):
                      # syscall interrupted; try again
                      pass
                  elif self.__closed:
                      raise EOFError()
                  else:
                      raise
              if got_timeout:
                  if self.__closed:
                      raise EOFError()
                  if check_rekey and (len(out) == 0) and self.__need_rekey:
                      raise NeedRekeyException()
                  self._check_keepalive()
          return out
docs: Read as close to N bytes as possible, blocking as long as necessary.
  
          @param n: number of bytes to read
          @type n: int
          @return: the data read
          @rtype: str
          @raise EOFError: if the socket was closed before all the bytes could
              be read