summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-10-11 11:13:06 (GMT)
committerGitHub <noreply@github.com>2023-10-11 11:13:06 (GMT)
commit79b81d1825cde3e051aa43d9e27edfbaeda84fda (patch)
treed8bfc71a1a2a8309aa1f9390bc91ea33e50609a4
parenta8b2d12a258a72963beb86406c69eb928863a09b (diff)
downloadcpython-79b81d1825cde3e051aa43d9e27edfbaeda84fda.zip
cpython-79b81d1825cde3e051aa43d9e27edfbaeda84fda.tar.gz
cpython-79b81d1825cde3e051aa43d9e27edfbaeda84fda.tar.bz2
[3.11] gh-76106: Remove the cleanup lock in test_socket (GH-110539) (GH-110700)
It does not already work (because it locks only addCleanup(), not doCleanups()), and it is no longer needed since the clean up procedure waits for all test threads to join. (cherry picked from commit f27b83090701b9c215e0d65f1f924fb9330cb649) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
-rw-r--r--Lib/test/test_socket.py26
1 files changed, 2 insertions, 24 deletions
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index bc93d99..3fceac3 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -201,26 +201,6 @@ class SocketUDPLITETest(SocketUDPTest):
self.serv = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDPLITE)
self.port = socket_helper.bind_port(self.serv)
-class ThreadSafeCleanupTestCase:
- """Subclass of unittest.TestCase with thread-safe cleanup methods.
-
- This subclass protects the addCleanup() method with a recursive lock.
-
- doCleanups() is called when the server completed, but the client can still
- be running in its thread especially if the server failed with a timeout.
- Don't put a lock on doCleanups() to prevent deadlock between addCleanup()
- called in the client and doCleanups() waiting for self.done.wait of
- ThreadableTest._setUp() (gh-110167)
- """
-
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
- self._cleanup_lock = threading.RLock()
-
- def addCleanup(self, *args, **kwargs):
- with self._cleanup_lock:
- return super().addCleanup(*args, **kwargs)
-
class SocketCANTest(unittest.TestCase):
@@ -613,8 +593,7 @@ class SocketListeningTestMixin(SocketTestBase):
self.serv.listen()
-class ThreadedSocketTestMixin(ThreadSafeCleanupTestCase, SocketTestBase,
- ThreadableTest):
+class ThreadedSocketTestMixin(SocketTestBase, ThreadableTest):
"""Mixin to add client socket and allow client/server tests.
Client socket is self.cli and its address is self.cli_addr. See
@@ -2698,7 +2677,7 @@ class BasicUDPLITETest(ThreadedUDPLITESocketTest):
# here assumes that datagram delivery on the local machine will be
# reliable.
-class SendrecvmsgBase(ThreadSafeCleanupTestCase):
+class SendrecvmsgBase:
# Base class for sendmsg()/recvmsg() tests.
# Time in seconds to wait before considering a test failed, or
@@ -4564,7 +4543,6 @@ class InterruptedRecvTimeoutTest(InterruptedTimeoutBase, UDPTestBase):
@unittest.skipUnless(hasattr(signal, "alarm") or hasattr(signal, "setitimer"),
"Don't have signal.alarm or signal.setitimer")
class InterruptedSendTimeoutTest(InterruptedTimeoutBase,
- ThreadSafeCleanupTestCase,
SocketListeningTestMixin, TCPTestBase):
# Test interrupting the interruptible send*() methods with signals
# when a timeout is set.