Skip to content

bpo-45187: Fix dangling threads in test_socket.CreateServerFunctionalTest #28422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions Lib/test/test_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -6528,13 +6528,6 @@ def test_dualstack_ipv6_family(self):
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:
Expand All @@ -6548,8 +6541,9 @@ def run(sock):

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):
Expand Down