Fix Windows server not accepting requests after returning from loop.create_server() #134259
+4
−0
Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!
Check out: eBank.nz (Art Generator) |
Netwrck.com (AI Tools) |
Text-Generator.io (AI API) |
BitBank.nz (Crypto AI) |
ReadingTime (Kids Reading) |
RewordGame |
BigMultiplayerChess |
WebFiddle |
How.nz |
Helix AI Assistant
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We have a flaky test where, very occasionally on Windows, a request to the server immediately after loop.create_server() gets rejected.
Comparing the code between selector and proactor loops, it appears that the proactor loop would need one more loop iteration than the selector loop, if I'm understanding the code correctly.
The proactor code is nested in a loop registered with call_soon(), so it won't start executing until one loop iteration later than the selector loop does:
cpython/Lib/asyncio/proactor_events.py
Lines 840 to 878 in 8d490b3
Compared to:
cpython/Lib/asyncio/selector_events.py
Lines 279 to 290 in 8d490b3
i.e. selector.register() is called in loop iteration 0, whereas proactor.accept() is called in loop iteration 1.