python / python/cpython

asyncio Event Loop does not provide warning about keeping a reference to returned task

未關閉
#155,502 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

docs topic-asyncio
主要語言
Python
星號
77.2k
分支
35.9k
PR 合併指標
PR 指標待擷取

描述

Documentation

The high level asyncio documentation warns that one should save the result of asyncio.create_task as the event loop only keeps weak references to tasks.
This same warning is not seen in the low level Event Loop documentation even though the same rules apply. The example code snippets also do not save a reference which would lead readers to believe it is safe to discard the result of the EventLoop.create_task function when it is not.

Relevant function in the high level documentation: https://docs.python.org/3/library/asyncio-task.html#asyncio.create_task

Relevant function in the low level documentation: https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.create_task

Linked PRs
  • gh-155599

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

比較 asyncio.create_task 的文件與兩個連結文件 URL 中的 asyncio.loop.create_task 區段。更新低階警告及其範例,使其反映高階文件中關於參照生命週期的指引,然後確認兩個區段是否一致。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
documentation
Issue 類型
文件
難度
2/5
預估耗時
1-3 小時
活躍度
停滯
描述清晰度
描述清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。