summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2023-01-13 21:24:57 (GMT)
committerGitHub <noreply@github.com>2023-01-13 21:24:57 (GMT)
commit1bc7a736837272b15ad3a7aa472977bc720d1033 (patch)
tree28668baf5172dc5758dc1b95037eaeee2d03d736 /Lib/test/test_asyncio
parentc00eb1eae6af3ee5b7e314add4606da4521bb8c5 (diff)
downloadcpython-1bc7a736837272b15ad3a7aa472977bc720d1033.zip
cpython-1bc7a736837272b15ad3a7aa472977bc720d1033.tar.gz
cpython-1bc7a736837272b15ad3a7aa472977bc720d1033.tar.bz2
GH-100573: Fix server hang caused by os.stat() on named pipe (Windows) (#100959)
Diffstat (limited to 'Lib/test/test_asyncio')
-rw-r--r--Lib/test/test_asyncio/test_windows_events.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_windows_events.py b/Lib/test/test_asyncio/test_windows_events.py
index 5033acc..a36119a 100644
--- a/Lib/test/test_asyncio/test_windows_events.py
+++ b/Lib/test/test_asyncio/test_windows_events.py
@@ -250,6 +250,46 @@ class ProactorTests(test_utils.TestCase):
proactor.sendto(sock, b'abc', addr=bad_address)
sock.close()
+ def test_client_pipe_stat(self):
+ res = self.loop.run_until_complete(self._test_client_pipe_stat())
+ self.assertEqual(res, 'done')
+
+ async def _test_client_pipe_stat(self):
+ # Regression test for https://github.com/python/cpython/issues/100573
+ ADDRESS = r'\\.\pipe\test_client_pipe_stat-%s' % os.getpid()
+
+ async def probe():
+ # See https://github.com/python/cpython/pull/100959#discussion_r1068533658
+ h = _overlapped.ConnectPipe(ADDRESS)
+ try:
+ _winapi.CloseHandle(_overlapped.ConnectPipe(ADDRESS))
+ except OSError as e:
+ if e.winerror != _overlapped.ERROR_PIPE_BUSY:
+ raise
+ finally:
+ _winapi.CloseHandle(h)
+
+ with self.assertRaises(FileNotFoundError):
+ await probe()
+
+ [server] = await self.loop.start_serving_pipe(asyncio.Protocol, ADDRESS)
+ self.assertIsInstance(server, windows_events.PipeServer)
+
+ errors = []
+ self.loop.set_exception_handler(lambda _, data: errors.append(data))
+
+ for i in range(5):
+ await self.loop.create_task(probe())
+
+ self.assertEqual(len(errors), 0, errors)
+
+ server.close()
+
+ with self.assertRaises(FileNotFoundError):
+ await probe()
+
+ return "done"
+
class WinPolicyTests(test_utils.TestCase):