-
-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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
gh-117657: fix race:sock_recv_impl suppressions for free-thread building #123697
Conversation
… building Signed-off-by: Manjusaka <[email protected]>
Signed-off-by: Manjusaka <[email protected]>
LGTM! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you diagnosed the issue correctly, but this changes the test so that it no longer actually tests the intended behavior of close()
.
Here is the (migrated) bug report that led to this test:
The point is to test that conn.close()
actually closes the underlying socket, so that a recv/select on the other end (self.cli
) with a short timeout returns immediately with an empty buffer.
- Restore the deleted
conn.close()
- Move the select/recv checks to the other thread (
_testClose
) so that each thread only accesses their own end of the connection.
We might need a few more tweaks after that.
Something like: def testClose(self):
conn, addr = self.serv.accept()
conn.close()
# Calling close() many times should be safe.
conn.close()
conn.close()
def _testClose(self):
self.cli.connect((HOST, self.port))
read, write, err = select.select([self.cli], [], [], support.SHORT_TIMEOUT)
self.assertEqual(read, [self.cli])
self.assertEqual(self.cli.recv(1), b'')
# The other end should be closed now, so select should immediately
# return with the socket ready for reading.
read, write, err = select.select([self.cli], [], [], 0)
self.assertEqual(read, [self.cli])
self.assertEqual(self.cli.recv(1), b'') |
Thanks for the tips, I'll update the patch ASAP |
Signed-off-by: Manjusaka <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This version of the PR has a few issues. The time.sleep(1.0)
adds an unnecessary one second delay. The 0.1
timeout will make the test too sensitive to timing variations and lead to spurious failures on heavily loaded machines.
Please see the suggested code in my comment at: #123697 (comment)
Signed-off-by: Manjusaka <[email protected]>
Signed-off-by: Manjusaka <[email protected]>
Signed-off-by: Manjusaka <[email protected]>
Thanks for the review. I have updated this PR. I think this version of this PR is similar to your suggested code. I add an extra step to check the socket which is generated bt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fix #117657