<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _readall(self, size):
 """ Read until all bytes are collected. Parameters size : int Number of bytes to read. """

        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