liveBook · Manning

ReadTransport

As explained in Python Concurrency with asyncio

ReadTransport is an asyncio transport abstraction for receiving data from a readable operating-system resource.

ReadTransport is an asyncio transport abstraction for receiving data from a readable operating-system resource. It separates data transmission from application behavior: the transport detects events, then calls methods on an asyncio.Protocol. section 8.2

The abstraction supports several practical operations:

  • Receive data from sources such as sockets, standard input, and other file-like objects. section 8.2 section 8.4
  • Deliver connection and data events to a protocol, which can respond through the transport. section 8.2
  • Connect a protocol to standard input through connect_read_pipe and StreamReaderProtocol, enabling asynchronous readline calls. section 8.4

Non-blocking standard input

Create a StreamReader, wrap it in StreamReaderProtocol, and connect it to sys.stdin with loop.connect_read_pipe. Await stdin_reader.readline() while scheduling delay tasks, so user input does not block the event loop. section 8.4

Figure 8.1 The class hierarchy of transports
08-01

Use the transport hierarchy to distinguish ReadTransport from WriteTransport and the combined Transport abstraction. section 8.2

How Python Concurrency with asyncio covers it

How deep it goes
Defines transport-protocol callbacks and demonstrates pipe integration, without descending into operating-system transport internals.
Examples
Uses a single HTTP GET client and an asynchronous command-line reader that schedules concurrent sleep tasks.
What you can do after
Apply it via asyncio to receive socket or standard-input data without blocking the event loop.
How it connects
Ties ReadTransport to asyncio.Protocol, StreamReaderProtocol, StreamReader, connect_read_pipe, sockets, and the event loop.

This explainer was generated by Manning's knowledge graph from the text of Python Concurrency with asyncio. The section links point to the parts of the book it draws on.