-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-92679: Clarify roles of asyncio protocols and transports #92680
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
cc3146f
Clarify roles of asyncio protocols and transports
arhadthedev 4e8479f
Fix: Transport and Protocol have no asyncio methods
arhadthedev bf927b7
Merge branch 'main' into asyncio-protocol-doc
arhadthedev 256b59d
Merge branch 'main' into asyncio-protocol-doc
arhadthedev 7f95a63
Merge branch 'main' into asyncio-protocol-doc
arhadthedev b630ee6
Merge branch 'main' into asyncio-protocol-doc
arhadthedev f0663c4
Merge branch 'main' into asyncio-protocol-doc
arhadthedev eb57bb6
Apply suggestions from code review
arhadthedev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,21 +23,21 @@ This documentation page covers both `Transports`_ and `Protocols`_. | |
|
||
.. rubric:: Introduction | ||
|
||
At the highest level, the transport is concerned with *how* bytes | ||
are transmitted, while the protocol determines *which* bytes to | ||
transmit (and to some extent when). | ||
The transport is an interface for a source of raw bytes, | ||
while the protocol represents a consumer of these bytes that may answer back. | ||
|
||
A different way of saying the same thing: a transport is an | ||
abstraction for a socket (or similar I/O endpoint) while a protocol | ||
is an abstraction for an application, from the transport's point | ||
of view. | ||
The protocol object may either generate and consume data on its own (like a | ||
fallback background sender behind :func:`~asyncio.loop.sendfile`), be an | ||
adapter for another I/O interface (like the | ||
:func:`~asyncio.StreamReader`/:func:`~asyncio.StreamWriter` backend), | ||
or play a role of a converter middle man between other transport and protocol | ||
(like the one created by :func:`~asyncio.loop.start_tls`). | ||
|
||
Yet another view is the transport and protocol interfaces | ||
together define an abstract interface for using network I/O and | ||
interprocess I/O. | ||
While the transport is actively puppeteered by an asyncio event loop, the | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "puppeteered" is a bit poetic for technical documentation. :-) |
||
protocol is passively triggered by events from the transport. | ||
|
||
There is always a 1:1 relationship between transport and protocol | ||
objects: the protocol calls transport methods to send data, | ||
There is always a 1:1 relationship between immediately communicating transport | ||
and protocol objects: the protocol calls transport methods to send data, | ||
while the transport calls protocol methods to pass it data that | ||
has been received. | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea what a "fallback background sender" would be or why
sendfile
is used here. I suppose I could look it up in the source, but that's asking a bit much in a section labeled "Introduction". It should speak for itself.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry for postponing the stuff for so long. I've got a load of thesis work in the university so I'll be free and able to address all the comments a couple of weeks later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I am patiently waiting.