def read_full ( stream ) : assert stream , "stream is required" chunks = [ ] chunk = yield stream . read ( ) while chunk : chunks . append ( chunk ) chunk = yield stream . read ( ) raise tornado . gen . Return ( b'' . join ( chunks ) )
python asyncio streaming data from iterable
Read the full contents of the given stream into memory .
def read_full(stream):
    """Read the full contents of the given stream into memory.

    :return:
        A future containing the complete stream contents.
    """
    assert stream, "stream is required"

    chunks = []
    chunk = yield stream.read()

    while chunk:
        chunks.append(chunk)
        chunk = yield stream.read()

    raise tornado.gen.Return(b''.join(chunks))