Skip to content

Commit 8066645

Browse files
committed
Now all _Threads operations occur in the main thread, so lock is unnecessary.
1 parent 97c7054 commit 8066645

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

Lib/socketserver.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -633,31 +633,25 @@ class _Threads(list):
633633
"""
634634
Joinable list of all non-daemon threads.
635635
"""
636-
def __init__(self):
637-
self._lock = threading.Lock()
638-
639636
def append(self, thread):
640637
if thread.daemon:
641638
return
642-
with self._lock:
643-
super().append(thread)
639+
super().append(thread)
644640

645641
def pop_all(self):
646-
with self._lock:
647-
self[:], result = [], self[:]
642+
self[:], result = [], self[:]
648643
return result
649644

650645
def join(self):
651646
for thread in self.pop_all():
652647
thread.join()
653648

654649
def reap(self):
655-
with self._lock:
656-
dead = [thread for thread in self if not thread.is_alive()]
657-
for thread in dead:
658-
# should not happen, but safe to ignore
659-
with contextlib.suppress(ValueError):
660-
self.remove(thread)
650+
dead = [thread for thread in self if not thread.is_alive()]
651+
for thread in dead:
652+
# should not happen, but safe to ignore
653+
with contextlib.suppress(ValueError):
654+
self.remove(thread)
661655

662656

663657
class _NoThreads:

0 commit comments

Comments
 (0)