Skip to content
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

asyncio: Don't wait for the stream to close #640

Merged
merged 2 commits into from
Dec 16, 2019
Merged

Conversation

florimondmanca
Copy link
Member

Fixes #634

Basically reverts #494.

Opening this as a POC - not sure this is the best way to fix things, or that this won't break other stuff.

@florimondmanca florimondmanca added http/2 Issues and PRs related to HTTP/2 concurrency Issues related to concurrency and usage of async libraries labels Dec 14, 2019
@florimondmanca
Copy link
Member Author

florimondmanca commented Dec 14, 2019

Note that #494 was originally added when we had still had #369 in. But in the meantime, the asyncio.Stream interface which #369 aimed at using to prevent DeprecationWarnings was removed from Python 3.8, and #369 was reverted via #423.

So in effect most discussions in #494 about whether to stream_writer.close() are outdated.

This is why I think the best way to go for us is to do as we did before #369: just stream_writer.close(), without waiting on the stream to actually close.

(From the asyncio code it seems this schedule the closing of the stream in the background - via a future - and I guess that this future will be closed by asyncio on program exit anyway, so we should be safe.)

@gdhameeja
Copy link
Contributor

Just a question.
Should we be removing call to stream_closed()? The docs suggest using stream_closed along with close()
https://docs.python.org/3/library/asyncio-stream.html#asyncio.StreamWriter.close

Copy link
Member

@tomchristie tomchristie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we neccessarily need such a long-form comment, but definately a yes on this one.

@tomchristie tomchristie merged commit c337938 into master Dec 16, 2019
@tomchristie tomchristie deleted the asyncio-client-close branch December 16, 2019 12:12
@tomchristie tomchristie mentioned this pull request Dec 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
concurrency Issues related to concurrency and usage of async libraries http/2 Issues and PRs related to HTTP/2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Client.close() can hang. (asyncio only).
3 participants