alexapy.aiohttp.streams
¶
Classes¶
StreamReader
: An enhancement of asyncio.StreamReader.DataQueue
: DataQueue is a general-purpose blocking queue with one reader.FlowControlDataQueue
: FlowControlDataQueue resumes and pauses an underlying stream.
- class alexapy.aiohttp.streams.StreamReader(protocol: alexapy.aiohttp.base_protocol.BaseProtocol, limit: int, *, timer: Optional[alexapy.aiohttp.helpers.BaseTimerContext] = None, loop: Optional[asyncio.events.AbstractEventLoop] = None)¶
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(): ...
Inheritance
- at_eof() bool ¶
Return True if the buffer is empty and ‘feed_eof’ was called.
- is_eof() bool ¶
Return True if ‘feed_eof’ was called.
- async readchunk() Tuple[bytes, bool] ¶
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.
- unread_data(data: bytes) None ¶
rollback reading some data from stream, inserting it to buffer head.
- class alexapy.aiohttp.streams.DataQueue(loop: asyncio.events.AbstractEventLoop)¶
DataQueue is a general-purpose blocking queue with one reader.
Inheritance
- class alexapy.aiohttp.streams.FlowControlDataQueue(protocol: alexapy.aiohttp.base_protocol.BaseProtocol, limit: int, *, loop: asyncio.events.AbstractEventLoop)¶
FlowControlDataQueue resumes and pauses an underlying stream.
It is a destination for parsed data.
Inheritance
Exceptions¶
EofStream
: eof stream indication.
- exception alexapy.aiohttp.streams.EofStream¶
eof stream indication.
Inheritance