summaryrefslogtreecommitdiffstats
path: root/Lib/socketserver.py
diff options
context:
space:
mode:
authorGregory P. Smith ext:(%20%5BGoogle%20Inc.%5D) <greg@krypto.org>2016-06-03 00:13:36 (GMT)
committerGregory P. Smith ext:(%20%5BGoogle%20Inc.%5D) <greg@krypto.org>2016-06-03 00:13:36 (GMT)
commitcef1f83c717d103575ab525040926db759d70d22 (patch)
tree029e5228009a86b9f9b4908faebf89fff9e26428 /Lib/socketserver.py
parent3bad04ca62bba6d2a83f1c1f42d8840103aef015 (diff)
downloadcpython-cef1f83c717d103575ab525040926db759d70d22.zip
cpython-cef1f83c717d103575ab525040926db759d70d22.tar.gz
cpython-cef1f83c717d103575ab525040926db759d70d22.tar.bz2
Issue #25931: Don't defining socketserver.Forking* names on platforms such
as Windows that do not support os.fork().
Diffstat (limited to 'Lib/socketserver.py')
-rw-r--r--Lib/socketserver.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/Lib/socketserver.py b/Lib/socketserver.py
index 70fdd6c..4f8a595 100644
--- a/Lib/socketserver.py
+++ b/Lib/socketserver.py
@@ -134,10 +134,12 @@ except ImportError:
import dummy_threading as threading
from time import monotonic as time
-__all__ = ["BaseServer", "TCPServer", "UDPServer", "ForkingUDPServer",
- "ForkingTCPServer", "ThreadingUDPServer", "ThreadingTCPServer",
+__all__ = ["BaseServer", "TCPServer", "UDPServer",
+ "ThreadingUDPServer", "ThreadingTCPServer",
"BaseRequestHandler", "StreamRequestHandler",
- "DatagramRequestHandler", "ThreadingMixIn", "ForkingMixIn"]
+ "DatagramRequestHandler", "ThreadingMixIn"]
+if hasattr(os, "fork"):
+ __all__.extend(["ForkingUDPServer","ForkingTCPServer", "ForkingMixIn"])
if hasattr(socket, "AF_UNIX"):
__all__.extend(["UnixStreamServer","UnixDatagramServer",
"ThreadingUnixStreamServer",
@@ -537,7 +539,9 @@ class UDPServer(TCPServer):
# No need to close anything.
pass
-class ForkingMixIn:
+if hasattr(os, "fork"):
+ # Non-standard indentation on this statement to avoid reindenting the body.
+ class ForkingMixIn:
"""Mix-in class to handle each request in a new process."""
@@ -647,8 +651,9 @@ class ThreadingMixIn:
t.start()
-class ForkingUDPServer(ForkingMixIn, UDPServer): pass
-class ForkingTCPServer(ForkingMixIn, TCPServer): pass
+if hasattr(os, "fork"):
+ class ForkingUDPServer(ForkingMixIn, UDPServer): pass
+ class ForkingTCPServer(ForkingMixIn, TCPServer): pass
class ThreadingUDPServer(ThreadingMixIn, UDPServer): pass
class ThreadingTCPServer(ThreadingMixIn, TCPServer): pass