mirror of https://github.com/python/cpython
bpo-45187: Fix dangling threads in test_socket.CreateServerFunctionalTest (GH-28422)
This commit is contained in:
parent
41551ee7e2
commit
51ebb7f4f5
|
@ -6528,13 +6528,6 @@ class CreateServerTest(unittest.TestCase):
|
||||||
class CreateServerFunctionalTest(unittest.TestCase):
|
class CreateServerFunctionalTest(unittest.TestCase):
|
||||||
timeout = support.LOOPBACK_TIMEOUT
|
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 echo_server(self, sock):
|
||||||
def run(sock):
|
def run(sock):
|
||||||
with sock:
|
with sock:
|
||||||
|
@ -6548,8 +6541,9 @@ class CreateServerFunctionalTest(unittest.TestCase):
|
||||||
|
|
||||||
event = threading.Event()
|
event = threading.Event()
|
||||||
sock.settimeout(self.timeout)
|
sock.settimeout(self.timeout)
|
||||||
self.thread = threading.Thread(target=run, args=(sock, ))
|
thread = threading.Thread(target=run, args=(sock, ))
|
||||||
self.thread.start()
|
thread.start()
|
||||||
|
self.addCleanup(thread.join, self.timeout)
|
||||||
event.set()
|
event.set()
|
||||||
|
|
||||||
def echo_client(self, addr, family):
|
def echo_client(self, addr, family):
|
||||||
|
|
Loading…
Reference in New Issue