code: def write(self, b):
          
          self._checkClosed()
          if isinstance(b, str):
              raise TypeError("can't write str to binary stream")
  
          with self._write_lock:
              self._write_buf.extend(b)
              self._flush_unlocked()
              return len(b)
docs: Write bytes to buffer.