-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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
Python 3.8 improperly warns about closing properly closed streams #82710
Comments
In testing AsyncSSH against Python 3.8, I noticed a large number of the following errors, even though I was properly closing streams before the objects holding them were garbage-collected.
After some investigation, the problem appears to be that closing a stream is not good enough to prevent the error. The check in asyncio doesn't properly handle the case where the stream is closing, but has not fully closed. Here's a simple test program that demonstrates this: import asyncio
async def tcp_client():
reader, writer = await asyncio.open_connection('127.0.0.1', 22)
writer.close()
asyncio.run(tcp_client()) It's possible to avoid this message by awaiting on writer.wait_closed(), but wait_closed() doesn't exist until Python 3.7, making it very difficult to write portable code and still avoid this message. |
I think the following change might address this problem: *** 233,239 ****
! if transport is not None:
def _on_reader_gc(self, wr):
transport = self._transport
! if transport is not None and not transport.is_closing():
# connection_made was called
context = {
'message': ('An open stream object is being garbage ' |
Sorry, I should have said that the change below was in the file asyncio/streams.py. |
Yes, I've experienced this bug. We need to fix this in 3.8.1. |
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:
The text was updated successfully, but these errors were encountered: