Skip to content

bpo-31234: Fix dangling thread in test_ftp/poplib #3540

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
merged 1 commit into from
Sep 13, 2017
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions Lib/test/test_ftplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,8 @@ def setUp(self):
def tearDown(self):
self.client.close()
self.server.stop()
# Explicitly clear the attribute to prevent dangling thread
self.server = None
asyncore.close_all(ignore_all=True)

def check_data(self, received, expected):
Expand Down Expand Up @@ -800,6 +802,8 @@ def setUp(self):
def tearDown(self):
self.client.close()
self.server.stop()
# Explicitly clear the attribute to prevent dangling thread
self.server = None
asyncore.close_all(ignore_all=True)

def test_af(self):
Expand Down Expand Up @@ -859,6 +863,8 @@ def setUp(self):
def tearDown(self):
self.client.close()
self.server.stop()
# Explicitly clear the attribute to prevent dangling thread
self.server = None
asyncore.close_all(ignore_all=True)

def test_control_connection(self):
Expand Down
7 changes: 6 additions & 1 deletion Lib/test/test_poplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ def setUp(self):
def tearDown(self):
self.client.close()
self.server.stop()
# Explicitly clear the attribute to prevent dangling thread
self.server = None

def test_getwelcome(self):
self.assertEqual(self.client.getwelcome(),
Expand Down Expand Up @@ -436,6 +438,8 @@ def tearDown(self):
# this exception
self.client.close()
self.server.stop()
# Explicitly clear the attribute to prevent dangling thread
self.server = None

def test_stls(self):
self.assertRaises(poplib.error_proto, self.client.stls)
Expand All @@ -461,7 +465,8 @@ def setUp(self):

def tearDown(self):
self.thread.join()
del self.thread # Clear out any dangling Thread objects.
# Explicitly clear the attribute to prevent dangling thread
self.thread = None

def server(self, evt, serv):
serv.listen()
Expand Down