Skip to content

Commit 68abb0d

Browse files
committed
separate code to remove a current thread into a function.
1 parent 287cc8c commit 68abb0d

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Lib/socketserver.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -655,11 +655,15 @@ def process_request_thread(self, request, client_address):
655655
try:
656656
self.shutdown_request(request)
657657
finally:
658-
thread = threading.current_thread()
659-
if not thread.daemon:
660-
with self._threads_lock:
661-
if self._threads is not None:
662-
self._threads.remove(thread)
658+
self._remove_thread()
659+
660+
def _remove_thread(self):
661+
"""Remove a current thread from threads list."""
662+
thread = threading.current_thread()
663+
if not thread.daemon:
664+
with self._threads_lock:
665+
if self._threads is not None:
666+
self._threads.remove(thread)
663667

664668
def process_request(self, request, client_address):
665669
"""Start a new thread to process the request."""

0 commit comments

Comments
 (0)