New submission from Simon Wrede <simwr...@student.liu.se>:
Documentation states that a reference must be kept when creating a task, https://docs.python.org/3/library/asyncio-task.html#asyncio.create_task. This is not done in StreamReaderProtocol, https://github.com/python/cpython/blob/main/Lib/asyncio/streams.py#L244. I've provided a simple example to force garbage collection of this task which results in `Task was destroyed but it is pending!`. Uncommenting the commented code of the example shows that the task is not destroyed when a reference is kept. Am I missing something or using the library incorrectly? I've followed the examples at https://docs.python.org/3/library/asyncio-stream.html#tcp-echo-server-using-streams. ---------- components: asyncio files: example.py messages: 410124 nosy: asvetlov, simwr872, yselivanov priority: normal severity: normal status: open title: Task created by StreamReaderProtocol gets garbage collected. versions: Python 3.10 Added file: https://bugs.python.org/file50552/example.py _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue46309> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com