diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_socket.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index aac213e..faf326d 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -7075,6 +7075,26 @@ class SendRecvFdsTests(unittest.TestCase): self.assertEqual(data, str(index).encode()) +class FreeThreadingTests(unittest.TestCase): + + def test_close_detach_race(self): + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + + def close(): + for _ in range(1000): + s.close() + + def detach(): + for _ in range(1000): + s.detach() + + t1 = threading.Thread(target=close) + t2 = threading.Thread(target=detach) + + with threading_helper.start_threads([t1, t2]): + pass + + def setUpModule(): thread_info = threading_helper.threading_setup() unittest.addModuleCleanup(threading_helper.threading_cleanup, *thread_info) |