Title: Theory / Unimportant / CS / Programming / Python / Async / Stream
Tags: automatedNewLineAfterCommaSpace
On every note of this deck, unless a note says otherwise:
Page: https://docs.python.org/3.10/library/asyncio-stream.html

Typ: asyncio.Stream
Meaning: high-level async/await-ready primitives to work with network connections.
Page: https://docs.python.org/3.10/library/asyncio-task.html
Context: python

Instruction: asyncio.open_connection(
  ip,
  port,
  *,
  limit=None,
  **kwargs
)
Language: python
Returns: coroutine for stream reader and writer for loop.create_connection(  host, port, **kwargs), of size at most limit
Typ: asyncio.Stream

Typ: StreamReader
Meaning: A stream in which one can read
Page: https://docs.python.org/3.10/library/asyncio-stream.html
Language: python

Typ: StreamWriter
Meaning: A stream in which one can write
Page: https://docs.python.org/3.10/library/asyncio-stream.html
Language: python

Instruction: asyncio.start_server(
  client_connected_cb,
  args...
)
Effect: call `client_connected_cb(reader, writer)`, where arguments are stream with limits, for each connection received by loop.create_connection(host, port, **kwargs)
Language: python
Typ: StreamWriter

Instruction: open_unix_connection
Effect: todo
Language: python
Typ: StreamWriter

Instruction: start_unix_server
Effect: todo
Language: python
Typ: StreamWriter

Instruction: stream_reader.read()
Language: python
Returns: coroutine, reads up to EOF
Variables: asyncio.StreamReader stream_reader
Typ: StreamWriter

Instruction: stream_reader.read(n)
Language: python
Returns: coroutine; at most n bytes from the reader, or up to EOF
Variables: asyncio.StreamReader stream_reader
Typ: StreamWriter

Instruction: stream_reader.readline()
Language: python
Returns: Coroutine, read up to \n or EOF
Variables: asyncio.StreamReader stream_reader
Typ: StreamWriter

Instruction: stream_reader.readexactly(n)
Language: python
Returns: coroutine returning exactly n bytes
Variables: asyncio.StreamReader stream_reader
Exception: Raise an IncompleteReadError if EOF is reached before n can be read.

Instruction: stream_reader.readuntil(separator=b'\n')
Language: python
Returns: coroutine returning stream read until separator
Variables: asyncio.StreamReader stream_reader
Exception: If EOF is reached before the complete separator is found, an IncompleteReadError exception is raised, and the internal buffer is reset.
If the amount of data read exceeds the configured stream limit, a LimitOverrunError exception is raised

Instruction: stream_reader.at_eof()
Language: python
Returns: Whether buffer is empty and feed_eof() was called
Variables: asyncio.StreamReader stream_reader

Typ: IncompleteReadError
Meaning: Error for stream reader where read didn't get the data expected.
Page: https://docs.python.org/3.10/library/asyncio-stream.html
Language: python
Variables: asyncio.StreamReader stream_reader
Subtype of: Error

Variable: icomplete_reader_error.partial
Meaning: partial data that was read before the exception was raised
Page: https://docs.python.org/3.10/library/asyncio-stream.html
Language: python
Variables: IncompleteReaderError icomplete_reader_error

Instruction: stream_writer.writelines(iterable_of_bytes)
Effect: attempts to write the iterable_of_bytes to the underlying socket immediately. If that fails, the data is queued in an internal write buffer until it can be sent.
Language: python
Variables: asyncio.StreamWrite stream_writer
Extra: The method should be used along with the drain() method

Instruction: stream_writer.close()
Effect: The method closes the stream and the underlying socket.
Language: python
Variables: asyncio.StreamWrite stream_writer

Instruction: stream_writer.write(data)
Effect: attempts to write the data to the underlying socket immediately. If that fails, the data is queued in an internal write buffer until it can be sent.
Language: python
Variables: asyncio.StreamWrite stream_writer
Extra: The method should be used along with the drain() method

Instruction: stream_writer.can_write_eof()
Language: python
Returns: whether the write end of the stream after the buffered write data is flushed.
Variables: asyncio.StreamWrite stream_writer

Instruction: stream_writer.write_eof()
Effect: Close the write end of the stream after the buffered write data is flushed.
Language: python
Variables: asyncio.StreamWrite stream_writer

Instruction: stream_writer.get_extra_info(
  name,
  default=None
)
Effect: Access optional transport information; see BaseTransport.get_extra_info() for details.
Language: python
Variables: asyncio.StreamWrite stream_writer

Instruction: stream_writer.drain()
Effect: awaitable. Wait until it is appropriate to resume writing to the stream.
Language: python
Variables: asyncio.StreamWrite stream_writer

Instruction: stream_writer.is_closing()
Language: python
Returns: the stream is closed or in the process of being closed.
Variables: asyncio.StreamWrite stream_writer

Instruction: stream_writer.wait_closed()
Effect: coroutine, waits until the stream is closed
Language: python
Variables: asyncio.StreamWrite stream_writer

Variable: stream_writer.transport
Meaning: the underlying asyncio transport.
Page: https://docs.python.org/3.10/library/asyncio-stream.html
Language: python
Variables: asyncio.StreamWrite stream_writer

Typ: exception asyncio.LimitOverrunError
Meaning: Reached the buffer size limit while looking for a separator.
Page: https://docs.python.org/3.10/library/asyncio-queue.html
Language: python
Extra: Raised by the asyncio stream APIs.

Variable: limit_overrun_error.consumed
Meaning: The total number of to be consumed bytes.
Page: https://docs.python.org/3.10/library/asyncio-queue.html
Language: python
Variables: limit_overrun_error: asyncio.LimitOverrunError
Extra: Raised by the asyncio stream APIs.