Skip to content
This repository has been archived by the owner on Feb 21, 2023. It is now read-only.

[question] why you are using close and wait_close instead of just one method? #707

Closed
vanyakosmos opened this issue Feb 22, 2020 · 1 comment
Labels

Comments

@vanyakosmos
Copy link

I don't understand the reasoning behind having two method. Can someone explain or at least point out where I can read about this design choice?
Why don't we have just one async method close which can be scheduled with asycnio.create_task or awaited in place if user whats to be sure that connections are closed?

@vanyakosmos vanyakosmos changed the title [question] why you are using close and wait_close instead of just othe method? [question] why you are using close and wait_close instead of just one method? Feb 22, 2020
@sbdchd
Copy link

sbdchd commented Sep 7, 2020

This is probably due to close and wait_close being defined on asyncio.StreamWritier class

https://docs.python.org/3/library/asyncio-stream.html#asyncio.StreamWriter.close

.close() will close the connection eventually so you don't need to call wait_close unless you don't want to proceed until the connection is actually closed.

Also note that wait_close was a new addition to that class in Python 3.7

related: python/asyncio#466

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants