Title: Task created by StreamReaderProtocol gets garbage collected.
Type: behavior Stage: patch review
Components: asyncio Versions: Python 3.11, Python 3.10, Python 3.9
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: asvetlov, kumaraditya303, simwr872, yselivanov
Priority: normal Keywords: patch

Created on 2022-01-08 23:35 by simwr872, last changed 2022-01-11 15:54 by AlexWaygood.

File name Uploaded Description Edit simwr872, 2022-01-08 23:35
Pull Requests
URL Status Linked Edit
PR 30505 open simwr872, 2022-01-09 17:05
Messages (3)
msg410124 - (view) Author: Simon Wrede (simwr872) * Date: 2022-01-08 23:35
Documentation states that a reference must be kept when creating a task,

This is not done in StreamReaderProtocol,

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
msg410134 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2022-01-09 07:20
Thanks for the bug report.

Seems like your analysis is correct.

Could you make a pull request which adds a task reference?
msg410310 - (view) Author: Alex Waygood (AlexWaygood) * (Python triager) Date: 2022-01-11 15:54
I'm removing 3.7 and 3.8 from the "versions" field, since those branches are old enough that they're now only accepting security-related patches.
Date User Action Args
2022-01-11 15:54:38AlexWaygoodsetnosy: - AlexWaygood
2022-01-11 15:54:26AlexWaygoodsetnosy: + AlexWaygood

messages: + msg410310
versions: - Python 3.7, Python 3.8
2022-01-11 15:42:46simwr872setversions: + Python 3.7, Python 3.8, Python 3.9, Python 3.11
2022-01-09 17:05:50simwr872setkeywords: + patch
stage: patch review
pull_requests: + pull_request28710
2022-01-09 07:56:19kumaraditya303setnosy: + kumaraditya303
2022-01-09 07:20:55asvetlovsetmessages: + msg410134
2022-01-08 23:37:52simwr872settype: behavior
2022-01-08 23:35:55simwr872create