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
Counter-intuitive behavior of Server.close() / wait_closed() #79033
Comments
|
**Summary**
**Details** After calling I'm not sure why the docs suggest to call I wrote a very simple server that merely accepts connections. I ran experiments where I saturate the server with incoming client connections and close it. I checked what happens around The current implementation appears to work as documented, assuming an rather low level interpretation of the docs of
Correct -- I'm not seeing any
Correct -- if "existing incoming client connections" is interpreted as "client connections that have gone through
I'm seeing calls to This is surprising for someone approaching asyncio from the public API rather than the internal implementation. This has practical consequences. Consider a server that keeps track of established connections via
|
|
For now I will use the following hack: server.close()
await server.wait_closed() |
|
Would it make sense to add This would be fragile but it would be an improvement over the current behavior, wouldn't it? |
|
IMO it should wait for all connections to be closed and the current behavior seems like an oversight. |
|
Yeah, there seem to be an unfinished thought here. Some of the logic I've discovered:
It does seem likely that Somebody should give this a try. CC: @aaugustin @1st1 |
|
I think I got it (GH-79033). I don't think we should backport this, even though it's fixing a bug -- code that got the close sequence wrong but managed to get away with it might suddenly hang. I need to think about a test for the correct behavior. |
It was a no-op when used as recommended (after close()). I had to debug one test (test__sock_sendfile_native_failure) -- the cleanup sequence for the test fixture was botched. Hopefully that's not a portend of problems in user code -- this has never worked so people may well be doing this wrong. :-( Co-authored-by: kumar aditya


aymericaugustin mannequin commentedSep 30, 2018
•
edited by bedevere-bot
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
Linked PRs
The text was updated successfully, but these errors were encountered: