diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2021-09-17 12:16:03 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-17 12:16:03 -0700 |
commit | 21711d53411e0da5976a9af591cd6ca97033f712 (patch) | |
tree | a8f94e05d60b9efa5e55eb61fbb48913aa9a804a | |
parent | a10726d3141d8f52a108c4daf70eefa29401e2fc (diff) | |
download | cpython-git-21711d53411e0da5976a9af591cd6ca97033f712.tar.gz |
bpo-45187: Fix dangling threads in test_socket.CreateServerFunctionalTest (GH-28422)
(cherry picked from commit 51ebb7f4f5e9bdcf8279a1d91be9569706f6bead)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
-rwxr-xr-x | Lib/test/test_socket.py | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index b6da4d09fe..5c15648b60 100755 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -6492,13 +6492,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: @@ -6512,8 +6505,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): |