From 78a1e0ccf16ce2c6c3f839eee0bd3c009e22acbb Mon Sep 17 00:00:00 2001 From: Kumar Aditya Date: Tue, 18 Mar 2025 10:22:41 +0000 Subject: [PATCH] fix race in closing socket --- Lib/test/test_asyncio/functional.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Lib/test/test_asyncio/functional.py b/Lib/test/test_asyncio/functional.py index 2934325b6dfbc7..555394b915de48 100644 --- a/Lib/test/test_asyncio/functional.py +++ b/Lib/test/test_asyncio/functional.py @@ -217,16 +217,15 @@ def stop(self): 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: