summaryrefslogtreecommitdiff
path: root/Lib/SocketServer.py
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2002-11-22 08:08:44 +0000
committerMartin v. Löwis <martin@v.loewis.de>2002-11-22 08:08:44 +0000
commit5e2ed6851c8f1add50f9545e405b73d2a98d42e9 (patch)
tree3347c3c52514796298a8ac5937ef96e602fca3f6 /Lib/SocketServer.py
parente7d650466ae22c53063a8794e051db71e2247eb9 (diff)
downloadcpython-5e2ed6851c8f1add50f9545e405b73d2a98d42e9.tar.gz
Patch #550765: Add daemon_threads flag.
Diffstat (limited to 'Lib/SocketServer.py')
-rw-r--r--Lib/SocketServer.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/Lib/SocketServer.py b/Lib/SocketServer.py
index e1d5ecbd6b..1928ad2c04 100644
--- a/Lib/SocketServer.py
+++ b/Lib/SocketServer.py
@@ -56,7 +56,8 @@ instance, a threading UDP server class is created as follows:
class ThreadingUDPServer(ThreadingMixIn, UDPServer): pass
The Mix-in class must come first, since it overrides a method defined
-in UDPServer!
+in UDPServer! Setting the various member variables also changes
+the behavior of the underlying server mechanism.
To implement a service, you must derive a class from
BaseRequestHandler and redefine its handle() method. You can then run
@@ -448,6 +449,10 @@ class ForkingMixIn:
class ThreadingMixIn:
"""Mix-in class to handle each request in a new thread."""
+ # Decides how threads will act upon termination of the
+ # main process
+ daemon_threads = 0
+
def process_request_thread(self, request, client_address):
"""Same as in BaseServer but as a thread.
@@ -466,6 +471,8 @@ class ThreadingMixIn:
import threading
t = threading.Thread(target = self.process_request_thread,
args = (request, client_address))
+ if self.daemon_threads:
+ t.setDaemon (1)
t.start()