# HG changeset patch # Parent 6c167d33a7701082cd6c91113dc44f42f8c8792b diff --git a/Doc/library/socketserver.rst b/Doc/library/socketserver.rst --- a/Doc/library/socketserver.rst +++ b/Doc/library/socketserver.rst @@ -39,11 +39,17 @@ When inheriting from :class:`ThreadingMixIn` for threaded connection behavior, you should explicitly declare how you want your threads to behave on an abrupt -shutdown. The :class:`ThreadingMixIn` class defines an attribute +shutdown. The :class:`ThreadingMixIn` class defines an attribute *daemon_threads*, which indicates whether or not the server should wait for -thread termination. You should set the flag explicitly if you would like threads -to behave autonomously; the default is :const:`False`, meaning that Python will -not exit until all threads created by :class:`ThreadingMixIn` have exited. +thread termination. You should set the flag explicitly if you would like +threads to behave autonomously; the default is :const:`None`, meaning that they +inherit the *daemon* flag from the parent thread. If you set it to +:const:`False`, Python will not exit until all threads created by +:class:`ThreadingMixIn` have exited. + +.. versionchanged:: 3.3 + previously, the *daemon_threads = False* flag was ignored. + Server classes have the same external methods and attributes, no matter what network protocol they use. diff --git a/Lib/socketserver.py b/Lib/socketserver.py --- a/Lib/socketserver.py +++ b/Lib/socketserver.py @@ -587,7 +587,7 @@ # Decides how threads will act upon termination of the # main process - daemon_threads = False + daemon_threads = None def process_request_thread(self, request, client_address): """Same as in BaseServer but as a thread. @@ -606,8 +606,8 @@ """Start a new thread to process the request.""" t = threading.Thread(target = self.process_request_thread, args = (request, client_address)) - if self.daemon_threads: - t.daemon = True + if self.daemon_threads is not None: + t.daemon = bool(self.daemon_threads) t.start()