8000 GH-100573: Fix server hang caused by os.stat() on named pipe (Windows) by gvanrossum · Pull Request #100959 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-100573: Fix server hang caused by os.stat() on named pipe (Windows) #100959

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 13, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix test using Eryk Sun's suggestion
  • Loading branch information
gvanrossum committed Jan 13, 2023
commit f4a9a9ae68d4dd9afab098523cf78166615adc7f
25 changes: 16 additions & 9 deletions Lib/test/test_asyncio/test_windows_events.py
B36E
Original file line number Diff line number Diff line change
Expand Up @@ -257,28 +257,35 @@ def test_client_pipe_stat(self):
async def _test_client_pipe_stat(self):
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):
os.stat(ADDRESS)
await probe()

[server] = await self.loop.start_serving_pipe(
asyncio.Protocol, ADDRESS)
[server] = await self.loop.start_serving_pipe(asyncio.Protocol, ADDRESS)
self.assertIsInstance(server, windows_events.PipeServer)

errors = []
self.loop.set_exception_handler(lambda *args: errors.append(args))

async def stat_it():
os.stat(ADDRESS)
self.loop.set_exception_handler(lambda _, data: errors.append(data))

for i in range(5):
await self.loop.create_task(stat_it())
await self.loop.create_task(probe())

self.assertEqual(len(errors), 0, errors)

server.close()

with self.assertRaises(FileNotFoundError):
os.stat(ADDRESS)
await probe()

return "done"

Expand Down
0