← All notes

Python asyncio streams: high-level network readers and writers

Answer: asyncio streams are high-level async/await primitives for sending and receiving data on network connections.

Opening a connection

These stream helpers avoid callbacks and also avoid low-level protocols and transports.

The TCP echo client example awaits asyncio.open_connection to get a reader and writer.

The default reader buffer cap is 64 KiB.

The rest of the arguments are passed directly to loop.create_connection.

Serving and Unix sockets

start_server invokes a callback whenever a new client connection is established.

The rest of the arguments are passed directly to loop.create_server.

A related function operates on Unix sockets.

To close the socket, call the writer's close method.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, Streams; CPython, Streams documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, Streams; CPython, Streams documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation.

Cite this

Permanent ID: iil:note:qq9bhf85

iinventedlight. 2026. "Python asyncio streams: high-level network readers and writers." iinventedlight Library, iil:note:qq9bhf85, version of 2026-11-26. https://iinventedlight.com/library/notes/python-asyncio-streams/. License: CC-BY-4.0.

@misc{iil_note_qq9bhf85,
  author = {{iinventedlight}},
  title = {{Python asyncio streams: high-level network readers and writers}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-26},
  url = {https://iinventedlight.com/library/notes/python-asyncio-streams/},
  note = {Permanent ID iil:note:qq9bhf85. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/python-asyncio-streams.md.