-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
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
Changes from 1 commit
d20c40c
4eddc01
68a3282
0fde2aa
f4a9a9a
6bcd7df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -250,6 +250,38 @@ def test_address_argument_type_error(self): | |
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): | ||
ADDRESS = r'\\.\pipe\test_client_pipe_stat-%s' % os.getpid() | ||
|
||
with self.assertRaises(FileNotFoundError): | ||
os.stat(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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In case the implementation of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried it and it does not reproduces the error. Note that I am using Windows 11. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I found the same problem. I also had to add two So I think I'd rather merge this as is, using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All that
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then how would you fix the test? os.close(os.open()) doesn’t fail without the fix. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I forgot that 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) In the test, 2/5 attempts at opening a second pipe connection fail with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we don’t need a test. All this is irrelevant for the fix. I can either delete the test, keep the PR as is, or close it unresolved. (Someone else can try again.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code in my last c
8000
omment reliably triggers the problem for me because it ensures that the client connects and disconnects from the server's next pipe instance, leaving the pipe in a broken state before the server calls If it comes to closing the PR or deleting the test, I vote for deleting the test. It should have been designed from the beginning to handle the broken pipe error. Not every aspect of a correct design has to be tested. |
||
|
||
for i in range(5): | ||
await self.loop.create_task(stat_it()) | ||
|
||
self.assertEqual(len(errors), 0, errors) | ||
|
||
server.close() | ||
|
||
with self.assertRaises(FileNotFoundError): | ||
os.stat(ADDRESS) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly here, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For that we need to wait for closing the server so There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't look like that's needed with the latest probe code. |
||
|
||
return "done" | ||
|
||
|
||
class WinPolicyTests(test_utils.TestCase): | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.