def METHOD_NAME(self, b):
    if self.closed:
        return ValueError('stream closed')
    logger.debug('write: %r', len(b))
    buffer = memoryview(b)
    # print("--", bytes(buffer))
    self.pos += len(buffer)
    # we need to copy it seems (otherwise if we use a buffered writer, it will reuse the memory)
    self.queue.put(bytes(buffer))
    # print(len(buffer))
    return len(buffer)