asyncio eager tasks have no awaited_by edge during their first step
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 35.9k
- Chỉ số merge pull request
- Chỉ số pull request đang chờ
Mô tả
Bug report
Bug description:
Task that created by eager task factory runs its first step before the awaited_by edge is registered. During this step the graph shows that this task is awaited by nobody
Repro:
import asyncio
async def child():
asyncio.print_call_graph()
await asyncio.sleep(0)
async def main():
await asyncio.gather(child())
loop = asyncio.new_event_loop()
loop.set_task_factory(asyncio.eager_task_factory)
loop.run_until_complete(main())
Expected:
* Task(name='Task-2', id=0x103544b90)
+ Call stack:
| File '/Users/timofeiivankov/cpython/repro.py', line 4, in async child()
+ Awaited by:
* Task(name='Task-1', id=0x103544d70)
+ Call stack:
| File '/Users/timofeiivankov/cpython/repro.py', line 8, in async main()
Actually:
* Task(name='Task-2', id=0x103058b90)
+ Call stack:
| File '/Users/timofeiivankov/cpython/repro.py', line 4, in async child()
With the default task factory it works fine as expected
Proposed fix: Register the edge inside the eager start and discard it when the step ends
I have a fix ready
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs
- gh-157300
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Chạy bản tái hiện asyncio được cung cấp với eager_task_factory và so sánh call graph của nó với task factory mặc định. Kiểm tra eager start và việc đăng ký awaited_by được mô tả trong báo cáo; hoàn thành khi bước con đầu tiên hiển thị parent của nó trong phần “Awaited by” mà không làm hỏng hành vi hiện có.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- backend
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 25/100