code: def _readall(self, size):
          
          data = b""
          while len(data) < size:
              d = self._read(size - len(data))
              if self._broken:
                  raise StopIteration
              if not d:
                  # NOTE (Buro/jgross): Force a yield here to another thread. In
                  # case the stream fails midstream, the spinning here causes
                  # the UI thread to lock up without yielding.
                  time.sleep(0)
                  continue
              data += d
          return data
docs: Read until all bytes are collected.
  
          Parameters
          ----------
          size : int
            Number of bytes to read.