Message354953
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.
An open stream object is being garbage collected; call "stream.close()" explicitly.
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. |
|
Date |
User |
Action |
Args |
2019-10-19 18:40:29 | Ron Frederick | set | recipients:
+ Ron Frederick, asvetlov, yselivanov |
2019-10-19 18:40:28 | Ron Frederick | set | messageid: <1571510429.0.0.996597968813.issue38529@roundup.psfhosted.org> |
2019-10-19 18:40:28 | Ron Frederick | link | issue38529 messages |
2019-10-19 18:40:28 | Ron Frederick | create | |
|