asyncio.StreamReader

class asyncio.StreamReader(limit=None, loop=None)

This class is not thread safe.

exception()

Get the exception.

feed_eof()

Acknowledge the EOF.

feed_data(data)

Feed data bytes in the internal buffer. Any operations waiting for the data will be resumed.

set_exception(exc)

Set the exception.

set_transport(transport)

Set the transport.

coroutine read(n=-1)

Read up to n bytes. If n is not provided, or set to -1, read until EOF and return all read bytes.

If the EOF was received and the internal buffer is empty, return an empty bytes object.

This method is a coroutine.

coroutine readline()

Read one line, where “line” is a sequence of bytes ending with \n.

If EOF is received, and \n was not found, the method will return the partial read bytes.

If the EOF was received and the internal buffer is empty, return an empty bytes object.

This method is a coroutine.

coroutine readexactly(n)

Read exactly n bytes. Raise an IncompleteReadError if the end of the stream is reached before n can be read, the IncompleteReadError.partial attribute of the exception contains the partial read bytes.

This method is a coroutine.

coroutine readuntil(separator=b'n')

Read data from the stream until separator is found.

On success, the data and separator will be removed from the internal buffer (consumed). Returned data will include the separator at the end.

Configured stream limit is used to check result. Limit sets the maximal length of data that can be returned, not counting the separator.

If an EOF occurs and the complete separator is still not found, an IncompleteReadError exception will be raised, and the internal buffer will be reset. The IncompleteReadError.partial attribute may contain the separator partially.

If the data cannot be read because of over limit, a LimitOverrunError exception will be raised, and the data will be left in the internal buffer, so it can be read again.

New in version 3.5.2.

at_eof()

Return True if the buffer is empty and feed_eof() was called.

doc_python
2016-10-07 17:27:00
Comments
Leave a Comment

Please login to continue.