liveBook · Manning

Data_received

As explained in Python Concurrency with asyncio

data_received is an asyncio protocol callback invoked when bytes arrive from the transport.

data_received is an asyncio.Protocol callback that a transport invokes whenever bytes arrive. Because one response may produce multiple calls, implementations accumulate the bytes in an internal buffer. section 8.2

Use data_received as part of a larger transport-and-protocol lifecycle:

  • Receive bytes from the transport each time the connection delivers data. section 8.2
  • Append successive calls to an internal response buffer rather than assuming one complete response. section 8.2
  • Wait for eof_received to determine that no further data_received calls will occur. section 8.2

Receiving an HTTP response

An asyncio.Protocol sends an HTTP GET request through connection_made. data_received collects the returned bytes, and eof_received marks the response complete so a Future can deliver it to get_response. section 8.2

How Python Concurrency with asyncio covers it

How deep it goes
Explains repeated callbacks, byte buffering, and completion through eof_received, without detailing parsing internals.
Examples
Demonstrates a single HTTP GET whose response arrives across data_received calls and completes when the connection closes.
What you can do after
Build a protocol that buffers incoming bytes and exposes the completed response through an awaitable Future.
How it connects
Connects asyncio.Protocol, Transport, connection_made, eof_received, Future, and HTTP response handling.

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.