bpo-45187: Fix dangling threads in test_socket.CreateServerFunctionalTest (GH-28422)

This commit is contained in:
Serhiy Storchaka 2021-09-17 21:56:41 +03:00 committed by GitHub
parent 41551ee7e2
commit 51ebb7f4f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 9 deletions

View File

@ -6528,13 +6528,6 @@ class CreateServerTest(unittest.TestCase):
class CreateServerFunctionalTest(unittest.TestCase):
timeout = support.LOOPBACK_TIMEOUT
def setUp(self):
self.thread = None
def tearDown(self):
if self.thread is not None:
self.thread.join(self.timeout)
def echo_server(self, sock):
def run(sock):
with sock:
@ -6548,8 +6541,9 @@ class CreateServerFunctionalTest(unittest.TestCase):
event = threading.Event()
sock.settimeout(self.timeout)
self.thread = threading.Thread(target=run, args=(sock, ))
self.thread.start()
thread = threading.Thread(target=run, args=(sock, ))
thread.start()
self.addCleanup(thread.join, self.timeout)
event.set()
def echo_client(self, addr, family):