-
-
Couldn't load subscription status.
- Fork 33.2k
gh-128319: Add missing server class attributes to socketserver docs #128320
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
base: main
Are you sure you want to change the base?
gh-128319: Add missing server class attributes to socketserver docs #128320
Conversation
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.
Thanks for doing this :)
Co-authored-by: Bénédikt Tran <[email protected]>
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.
👍🏻 LGTM! With conditions (see knit-picky inline comment)
🙇 Thanks @stephen-hansen; These document drafts have already been useful to me.
| The maximum amount of data (in bytes) to receive at once. If a packet is | ||
| too large for the buffer, then the excess bytes beyond :attr:`max_packet_size` | ||
| are discarded. The default value is usually ``8192``, but this can be | ||
| overridden by subclasses. |
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.
LGTM! With conditions:
Please consider clarifying if the term "data" here, means without IP/UDP headers with something like:
| The maximum amount of data (in bytes) to receive at once. If a packet is | |
| too large for the buffer, then the excess bytes beyond :attr:`max_packet_size` | |
| are discarded. The default value is usually ``8192``, but this can be | |
| overridden by subclasses. | |
| The maximum amount of data (in bytes) to receive at once. If a packet's | |
| payload (excluding headers) is too large for the buffer, then the excess | |
| bytes beyond :attr:`max_packet_size` are discarded. The default value | |
| is usually ``8192``, but this can be overridden by subclasses. |
or if this really is the literal maximum packet size:
| The maximum amount of data (in bytes) to receive at once. If a packet is | |
| too large for the buffer, then the excess bytes beyond :attr:`max_packet_size` | |
| are discarded. The default value is usually ``8192``, but this can be | |
| overridden by subclasses. | |
| The maximum amount of data (in bytes) to receive at once. If a packet's | |
| payload (including headers) is too large for the buffer, then the excess | |
| bytes beyond :attr:`max_packet_size` are discarded. The default value | |
| is usually ``8192``, but this can be overridden by subclasses. |
Rational:
Omission of any mention of header when talking about a "packet" being "too large" is somewhat misleading to the reader.
not sure if going further is relevant to the python side, but for convenience sake I'll mention, the typical 20-byte IPV4 header (RFC-791 gives 20-byte base header, 40-byte maximum options) and the required 8-byte header assuming UDP (RFC-768).
Hopefully this helps.
Additional considerations (TL;DR):
- MTU, and fragmentation boundaries are possible reasons to want to change the default (eg. expected max burst count * max packet size (including headers) on network path with values of
5 * (1500 - 20 - 40 - 8)=7160so the default is somewhat larger than the similar stream sockets'request_queue_sizedefault) - UDP max packet size (after headers) is a possible (albeit unlikely) reason for increasing the size well beyond the default of
8192
Just doing some cleanup of the socketserver docs regarding class attributes as mentioned in the linked issue.
address_familyattribute from instance attributes to class attributes.allow_reuse_port.max_packet_size(note UDP only).request_queue_sizeto denote TCP only.📚 Documentation preview 📚: https://cpython-previews--128320.org.readthedocs.build/