asyncio.StreamWriter

class asyncio.StreamWriter(transport, protocol, reader, loop)

Wraps a Transport.

This exposes write(), writelines(), can_write_eof(), write_eof(), get_extra_info() and close(). It adds drain() which returns an optional Future on which you can wait for flow control. It also adds a transport attribute which references the Transport directly.

This class is not thread safe.

transport

Transport.

can_write_eof()

Return True if the transport supports write_eof(), False if not. See WriteTransport.can_write_eof().

close()

Close the transport: see BaseTransport.close().

coroutine drain()

Let the write buffer of the underlying transport a chance to be flushed.

The intended use is to write:

w.write(data)
yield from w.drain()

When the size of the transport buffer reaches the high-water limit (the protocol is paused), block until the size of the buffer is drained down to the low-water limit and the protocol is resumed. When there is nothing to wait for, the yield-from continues immediately.

Yielding from drain() gives the opportunity for the loop to schedule the write operation and flush the buffer. It should especially be used when a possibly large amount of data is written to the transport, and the coroutine does not yield-from between calls to write().

This method is a coroutine.

get_extra_info(name, default=None)

Return optional transport information: see BaseTransport.get_extra_info().

write(data)

Write some data bytes to the transport: see WriteTransport.write().

writelines(data)

Write a list (or any iterable) of data bytes to the transport: see WriteTransport.writelines().

write_eof()

Close the write end of the transport after flushing buffered data: see WriteTransport.write_eof().

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

Please login to continue.