From: Kumar Aditya Date: Tue, 18 Mar 2025 10:50:47 +0000 (+0530) Subject: gh-128002: fix tsan race in closing socket in `test_sslproto` (#131399) X-Git-Tag: v3.14.0a7~328 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ab6333f7f56554bfd6c01eff567ddfb163a3dae6;p=thirdparty%2FPython%2Fcpython.git gh-128002: fix tsan race in closing socket in `test_sslproto` (#131399) --- diff --git a/Lib/test/test_asyncio/functional.py b/Lib/test/test_asyncio/functional.py index 2934325b6dfb..555394b915de 100644 --- a/Lib/test/test_asyncio/functional.py +++ b/Lib/test/test_asyncio/functional.py @@ -217,16 +217,15 @@ class TestThreadedServer(SocketThread): pass finally: super().stop() - - def run(self): - try: - with self._sock: - self._sock.setblocking(False) - self._run() - finally: + self._sock.close() self._s1.close() self._s2.close() + + def run(self): + self._sock.setblocking(False) + self._run() + def _run(self): while self._active: if self._clients >= self._max_clients: