-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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-98388: Add tests for happy eyeballs and its internal workings #98389
base: main
Are you sure you want to change the base?
GH-98388: Add tests for happy eyeballs and its internal workings #98389
Conversation
One of the new tests may fail intermittently due to python#86296.
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've added the "skip news" label because this is a test-only PR.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
I have made the test that exposes #86296 fail more consistently on my computer. Let's see whether these CI tests fail. I guess the next thing to consider is: What to do with this failing test? On 3.11 and above I can replace |
On my Intel Mac I don't see these tests fail yet. But it seems they are failing in CI, so I believe you. I'd say let's first prepare a fix that uses timeout and see if that passes everything. For the 3.10 backport we have to do something completely different. I wonder if the key problem here isn't the one that caused so much trouble for the Semaphore class as well -- you can await a future, and catch CancelledError, but that doesn't mean the future was cancelled, it could mean the current task was cancelled after the future already completed. Maybe there's still a path through the code that doesn't account for that, somehow? |
This solution is compatible with all Python versions, and should pass all tests.
I got some inspiration from my past comments, and implemented a fix that's available on older Python versions as well. The general approach is probably applicable to more situations: by waiting on the inner task with |
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.
Once #98518 lands, please remove the implementation changes and only add tests.
As mentioned by @kumaraditya303: Now that #98518 has landed, would you like to modify this PR to only include the tests? Thanks. |
The OP has no activity since January. |
Well, working with diff using the mobile version of GitHub is extremely hard. I'll restore the deleted file in an hour after getting to a proper computer with a proper mouse. |
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 basically LGTM, I only have very minor nits.
@arhadthedev, would you take over this PR, since @twisteroidambassador seems to have disappeared? I think it would be good to land this and backport it to 3.12. At the very least you could review my suggestions, if you agree with everything I can merge.
@willingc Did you want to add anything?
FOUR_C = (socket.AF_INET, 0, 0, '', ('192.0.2.3', 7)) | ||
FOUR_D = (socket.AF_INET, 0, 0, '', ('192.0.2.4', 8)) | ||
|
||
addrinfos = [SIX_A, SIX_B, SIX_C, SIX_D, FOUR_A, FOUR_B, FOUR_C, FOUR_D] |
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.
Would it be a more thorough test if we mixed up the order a bit, e.g. like this?
addrinfos = [SIX_A, SIX_B, SIX_C, SIX_D, FOUR_A, FOUR_B, FOUR_C, FOUR_D] | |
addrinfos = [SIX_A, SIX_B, SIX_C, FOUR_A, FOUR_B, FOUR_C, FOUR_D, SIX_D] |
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 @gvanrossum.
# There's a potential race condition here: | ||
# https://github.com/python/cpython/issues/86296 | ||
# As with any race condition, it can be difficult to reproduce. | ||
# This test may not fail every time. |
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.
Please add a note to this comment that the race condition has been fixed in 3.12, e.g.
# There's a potential race condition here: | |
# https://github.com/python/cpython/issues/86296 | |
# As with any race condition, it can be difficult to reproduce. | |
# This test may not fail every time. | |
# There's a potential race condition here (fixed in Python 3.12): | |
# https://github.com/python/cpython/issues/86296 | |
# As with any race condition, it can be difficult to reproduce. | |
# This test may not fail every time. |
It would be great if @arhadthedev can take over this PR, since I don't think I'll have time to work on this in the foreseeable future. Thanks in advance to everyone! |
GH-98388