mirror of
https://github.com/python/cpython.git
synced 2025-09-29 19:56:59 +00:00
[3.6] bpo-31234: Fix dangling thread in test_ftp/poplib (#3554)
* bpo-31234: Fix dangling thread in test_ftp/poplib (#3540) Explicitly clear the server attribute in test_ftplib and test_poplib to prevent dangling thread. (cherry picked from commitd403a29c00
) * bpo-31234: Fix dangling thread in test_ftplib (#3544) Clear also self.server_thread attribute in TestTimeouts.tearDown(). (cherry picked from commitb157ce1e58
)
This commit is contained in:
parent
d99e85b9f6
commit
ef323e8d82
2 changed files with 17 additions and 1 deletions
|
@ -470,6 +470,9 @@ class TestFTPClass(TestCase):
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.client.close()
|
self.client.close()
|
||||||
self.server.stop()
|
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):
|
def check_data(self, received, expected):
|
||||||
self.assertEqual(len(received), len(expected))
|
self.assertEqual(len(received), len(expected))
|
||||||
|
@ -799,6 +802,9 @@ class TestIPv6Environment(TestCase):
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.client.close()
|
self.client.close()
|
||||||
self.server.stop()
|
self.server.stop()
|
||||||
|
# Explicitly clear the attribute to prevent dangling thread
|
||||||
|
self.server = None
|
||||||
|
asyncore.close_all(ignore_all=True)
|
||||||
|
|
||||||
def test_af(self):
|
def test_af(self):
|
||||||
self.assertEqual(self.client.af, socket.AF_INET6)
|
self.assertEqual(self.client.af, socket.AF_INET6)
|
||||||
|
@ -857,6 +863,9 @@ class TestTLS_FTPClass(TestCase):
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.client.close()
|
self.client.close()
|
||||||
self.server.stop()
|
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):
|
def test_control_connection(self):
|
||||||
self.assertNotIsInstance(self.client.sock, ssl.SSLSocket)
|
self.assertNotIsInstance(self.client.sock, ssl.SSLSocket)
|
||||||
|
@ -979,6 +988,8 @@ class TestTimeouts(TestCase):
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
ftplib.FTP.port = self.old_port
|
ftplib.FTP.port = self.old_port
|
||||||
self.server_thread.join()
|
self.server_thread.join()
|
||||||
|
# Explicitly clear the attribute to prevent dangling thread
|
||||||
|
self.server_thread = None
|
||||||
|
|
||||||
def server(self):
|
def server(self):
|
||||||
# This method sets the evt 3 times:
|
# This method sets the evt 3 times:
|
||||||
|
|
|
@ -254,6 +254,8 @@ class TestPOP3Class(TestCase):
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.client.close()
|
self.client.close()
|
||||||
self.server.stop()
|
self.server.stop()
|
||||||
|
# Explicitly clear the attribute to prevent dangling thread
|
||||||
|
self.server = None
|
||||||
|
|
||||||
def test_getwelcome(self):
|
def test_getwelcome(self):
|
||||||
self.assertEqual(self.client.getwelcome(),
|
self.assertEqual(self.client.getwelcome(),
|
||||||
|
@ -436,6 +438,8 @@ class TestPOP3_TLSClass(TestPOP3Class):
|
||||||
# this exception
|
# this exception
|
||||||
self.client.close()
|
self.client.close()
|
||||||
self.server.stop()
|
self.server.stop()
|
||||||
|
# Explicitly clear the attribute to prevent dangling thread
|
||||||
|
self.server = None
|
||||||
|
|
||||||
def test_stls(self):
|
def test_stls(self):
|
||||||
self.assertRaises(poplib.error_proto, self.client.stls)
|
self.assertRaises(poplib.error_proto, self.client.stls)
|
||||||
|
@ -461,7 +465,8 @@ class TestTimeouts(TestCase):
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.thread.join()
|
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):
|
def server(self, evt, serv):
|
||||||
serv.listen()
|
serv.listen()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue