streams

Module Contents

Classes

EofStream() eof stream indication.
AsyncStreamIterator(self,read_func)
ChunkTupleAsyncStreamIterator()
AsyncStreamReaderMixin()
StreamReader(self,protocol) An enhancement of asyncio.StreamReader.
EmptyStreamReader()
DataQueue(self) DataQueue is a general-purpose blocking queue with one reader.
FlowControlDataQueue(self,protocol) FlowControlDataQueue resumes and pauses an underlying stream.
class EofStream

eof stream indication.

class AsyncStreamIterator(read_func)
__init__(read_func)
__aiter__()
__anext__()
class ChunkTupleAsyncStreamIterator
__anext__()
class AsyncStreamReaderMixin
__aiter__()
iter_chunked(n)

Returns an asynchronous iterator that yields chunks of size n.

Python-3.5 available for Python 3.5+ only

iter_any()

Returns an asynchronous iterator that yields all the available data as soon as it is received

Python-3.5 available for Python 3.5+ only

iter_chunks()

Returns an asynchronous iterator that yields chunks of data as they are received by the server. The yielded objects are tuples of (bytes, bool) as returned by the StreamReader.readchunk method.

Python-3.5 available for Python 3.5+ only

class StreamReader(protocol)

An enhancement of asyncio.StreamReader.

Supports asynchronous iteration by line, chunk or as available:

async for line in reader:
    ...
async for chunk in reader.iter_chunked(1024):
    ...
async for slice in reader.iter_any():
    ...
__init__(protocol)
__repr__()
exception()
set_exception(exc)
on_eof(callback)
feed_eof()
is_eof()

Return True if ‘feed_eof’ was called.

at_eof()

Return True if the buffer is empty and ‘feed_eof’ was called.

wait_eof()
unread_data(data)

rollback reading some data from stream, inserting it to buffer head.

feed_data(data, size=0)
begin_http_chunk_receiving()
end_http_chunk_receiving()
_wait(func_name)
readline()
read(n=None)
readany()
readchunk()

Returns a tuple of (data, end_of_http_chunk). When chunked transfer encoding is used, end_of_http_chunk is a boolean indicating if the end of the data corresponds to the end of a HTTP chunk , otherwise it is always False.

readexactly(n)
read_nowait(n=None)
_read_nowait_chunk(n)
_read_nowait(n)
class EmptyStreamReader
exception()
set_exception(exc)
on_eof(callback)
feed_eof()
is_eof()
at_eof()
wait_eof()
feed_data(data)
readline()
read(n=None)
readany()
readchunk()
readexactly(n)
read_nowait()
class DataQueue

DataQueue is a general-purpose blocking queue with one reader.

__init__()
__len__()
is_eof()
at_eof()
exception()
set_exception(exc)
feed_data(data, size=0)
feed_eof()
read()
__aiter__()
class FlowControlDataQueue(protocol)

FlowControlDataQueue resumes and pauses an underlying stream.

It is a destination for parsed data.

__init__(protocol)
feed_data(data, size)
read()