Skip to content

Commit 21711d5

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

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
@@ -6492,13 +6492,6 @@ def test_dualstack_ipv6_family(self):
64926492
class CreateServerFunctionalTest(unittest.TestCase):
64936493
timeout = support.LOOPBACK_TIMEOUT
64946494

6495-
def setUp(self):
6496-
self.thread = None
6497-
6498-
def tearDown(self):
6499-
if self.thread is not None:
6500-
self.thread.join(self.timeout)
6501-
65026495
def echo_server(self, sock):
65036496
def run(sock):
65046497
with sock:
@@ -6512,8 +6505,9 @@ def run(sock):
65126505

65136506
event = threading.Event()
65146507
sock.settimeout(self.timeout)
6515-
self.thread = threading.Thread(target=run, args=(sock, ))
6516-
self.thread.start()
6508+
thread = threading.Thread(target=run, args=(sock, ))
6509+
thread.start()
6510+
self.addCleanup(thread.join, self.timeout)
65176511
event.set()
65186512

65196513
def echo_client(self, addr, family):

0 commit comments

Comments
 (0)