https://github.com/python/cpython/commit/8a46a2ec5032c5eb1bc3c6bb0fc2422ac9b2cc53
commit: 8a46a2ec5032c5eb1bc3c6bb0fc2422ac9b2cc53
branch: main
author: Nadeshiko Manju <m...@manjusaka.me>
committer: colesbury <colesb...@gmail.com>
date: 2024-09-06T15:00:28-04:00
summary:

gh-117657: Fix file descriptor race in test_socket.py (#123697)

files:
M Lib/test/test_socket.py
M Tools/tsan/suppressions_free_threading.txt

diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index 628f806c78959d..e449fa65aceff9 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -4806,15 +4806,13 @@ def testInterruptedSendmsgTimeout(self):
 
 
 class TCPCloserTest(ThreadedTCPSocketTest):
-
     def testClose(self):
-        conn, addr = self.serv.accept()
-        conn.close()
+        conn, _ = self.serv.accept()
 
-        sd = self.cli
-        read, write, err = select.select([sd], [], [], 1.0)
-        self.assertEqual(read, [sd])
-        self.assertEqual(sd.recv(1), b'')
+        read, _, _ = select.select([conn], [], [], support.SHORT_TIMEOUT)
+        self.assertEqual(read, [conn])
+        self.assertEqual(conn.recv(1), b'x')
+        conn.close()
 
         # Calling close() many times should be safe.
         conn.close()
@@ -4822,7 +4820,10 @@ def testClose(self):
 
     def _testClose(self):
         self.cli.connect((HOST, self.port))
-        time.sleep(1.0)
+        self.cli.send(b'x')
+        read, _, _ = select.select([self.cli], [], [], support.SHORT_TIMEOUT)
+        self.assertEqual(read, [self.cli])
+        self.assertEqual(self.cli.recv(1), b'')
 
 
 class BasicSocketPairTest(SocketPairTest):
diff --git a/Tools/tsan/suppressions_free_threading.txt 
b/Tools/tsan/suppressions_free_threading.txt
index 78449aed4009d3..e5eb665ae212de 100644
--- a/Tools/tsan/suppressions_free_threading.txt
+++ b/Tools/tsan/suppressions_free_threading.txt
@@ -15,8 +15,6 @@ race:set_allocator_unlocked
 # These entries are for warnings that trigger in a library function, as called
 # by a CPython function.
 
-# https://gist.github.com/swtaarrs/8e0e365e1d9cecece3269a2fb2f2b8b8
-race:sock_recv_impl
 # https://gist.github.com/swtaarrs/08dfe7883b4c975c31ecb39388987a67
 race:free_threadstate
 

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to