Skip to content

socketserver: Add missing ForkingUnixStreamServer and ForkingUnixDatagramServer servers #103673

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
jb2170 opened this issue Apr 22, 2023 · 2 comments
Assignees
Labels
type-feature A feature request or enhancement

Comments

@jb2170
Copy link
Contributor

jb2170 commented Apr 22, 2023

Enhancement

This issue / PR addresses two missing servers from the socketserver module

Current behaviour

socketserver has the following

Protocol Family Simple Forking Threading
TCP AF_INET TCPServer ForkingTCPServer ThreadingTCPServer
TCP AF_UNIX UnixStreamServer ??? ThreadingUnixStreamServer
UDP AF_INET UDPServer ForkingUDPServer ThreadingUDPServer
UDP AF_UNIX UnixDatagramServer ??? ThreadingUnixDatagramServer

Observe the two gaps marked by "???"

Proposal

In the case hasattr(socket, "AF_UNIX") and hasattr(os, "fork") we enable the two missing servers as

class ForkingUnixStreamServer(ForkingMixIn, UnixStreamServer): pass

class ForkingUnixDatagramServer(ForkingMixIn, UnixDatagramServer): pass

These follow the established naming convention

This enhancement is completely forwards/backwards compatible

Mentions in the documentation are included in the PR corresponding to this issue

Pitch

Googling ForkingUnixStreamServer shows a few people / codebases which define such a class in the same manner as above. I myself have done so in a project.

These classes seem to have been overlooked because they require two if checks for hasattr(socket, "AF_UNIX") and hasattr(os, "fork").

It seems clear to me therefore that these two classes should be added to the socketserver standard library module

Some people prefer forks to threads

Linked PRs

@jb2170 jb2170 added the type-feature A feature request or enhancement label Apr 22, 2023
@gpshead gpshead self-assigned this Apr 23, 2023
jb2170 added a commit to jb2170/cpython that referenced this issue Apr 24, 2023
gpshead added a commit to jb2170/cpython that referenced this issue Apr 24, 2023
gpshead added a commit that referenced this issue Apr 24, 2023
…mServer socketservers (#103674)

sockserver gains ForkingUnixStreamServer and ForkingUnixDatagramServer classes for consistency with all of the others. Ironically these existed but were buried in our test suite.

Addresses #103673 

<!-- gh-issue-number: gh-103673 -->
* Issue: gh-103673
<!-- /gh-issue-number -->

---------

Co-authored-by: Gregory P. Smith <[email protected]>
Co-authored-by: Nikita Sobolev <[email protected]>
@jb2170
Copy link
Contributor Author

jb2170 commented Apr 24, 2023

Completed by d94b3a6, nice one!

@jb2170 jb2170 closed this as completed Apr 24, 2023
@gpshead
Copy link
Member

gpshead commented Apr 24, 2023

Thanks!

carljm added a commit to carljm/cpython that referenced this issue Apr 24, 2023
* main:
  pythongh-103801: Tools/wasm linting and formatting (python#103796)
  pythongh-103673: Add missing ForkingUnixStreamServer and ForkingUnixDatagramServer socketservers (python#103674)
  pythongh-95795: Move types.next_version_tag to PyInterpreterState (pythongh-102343)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants