Description
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