Skip to content

Commit 6c50f23

Browse files
bpo-45187: Fix dangling threads in test_socket.CreateServerFunctionalTest (GH-28422) (GH-28424)
(cherry picked from commit 51ebb7f) Co-authored-by: Serhiy Storchaka <[email protected]>
1 parent 0f4449e commit 6c50f23

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

Lib/test/test_socket.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6482,13 +6482,6 @@ def test_dualstack_ipv6_family(self):
64826482
class CreateServerFunctionalTest(unittest.TestCase):
64836483
timeout = support.LOOPBACK_TIMEOUT
64846484

6485-
def setUp(self):
6486-
self.thread = None
6487-
6488-
def tearDown(self):
6489-
if self.thread is not None:
6490-
self.thread.join(self.timeout)
6491-
64926485
def echo_server(self, sock):
64936486
def run(sock):
64946487
with sock:
@@ -6502,8 +6495,9 @@ def run(sock):
65026495

65036496
event = threading.Event()
65046497
sock.settimeout(self.timeout)
6505-
self.thread = threading.Thread(target=run, args=(sock, ))
6506-
self.thread.start()
6498+
thread = threading.Thread(target=run, args=(sock, ))
6499+
thread.start()
6500+
self.addCleanup(thread.join, self.timeout)
65076501
event.set()
65086502

65096503
def echo_client(self, addr, family):

0 commit comments

Comments
 (0)