TaskGroup around yield in fixture doesn't terminate with exceptions
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- python
- Lĩnh vực
- testing-qa
Hướng nghiên cứu
Bắt đầu với fixture và test tối thiểu trong tests/conftest.py từ ví dụ được liên kết, sau đó chạy chúng để tái hiện hiện tượng treo. Đọc công thức kết thúc của asyncio TaskGroup và theo dõi cách pytest-asyncio xử lý teardown của fixture async-generator. Hoàn thành khi exception bị trì hoãn hủy task còn lại và khiến fixture hoặc test thất bại thay vì treo vô thời hạn.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I tried to make a fixture to throw an exception after a certain amount of time to catch deadlocks in my tests, but the exception isn't causing the TaskGroup to error out.
Here is a minimal example fixture that interacts with a literally trivial test
https://github.com/sawalls/pytest-asyncio-example/blob/main/tests/conftest.py
@fixture(scope="function")
async def async_buddy():
mytasks = set()
async def forever_loop():
while True:
await sleep(1)
async def exception_task():
await sleep(5)
raise Exception("This is an exception")
async with TaskGroup() as tg:
mytasks.add(tg.create_task(forever_loop()))
mytasks.add(tg.create_task(exception_task()))
yield
---
async def test_example(async_buddy):
pass
It's inspired by the recipe in the python docs to terminate a TaskGroup:
https://docs.python.org/3/library/asyncio-task.html#terminating-a-task-group
Expected behavior:
- Make TaskGroup
- Make Tasks
- Yield to test, which returns immediately
- Enter context manager waiting for tasks
- Get Exception from exception task, cancel all tasks, and throw out of the fixture
Observed behavior:
- Make TaskGroup
- Make Tasks
- Yield to test, which returns immediately (so at this point the test has reported success)
- Enter context manager waiting for tasks
- Hangs indefinitely
Please let me know if there's anything about my intentions I can make more clear or documents I should read to get a better understanding.
Also, if you want to direct me at some code to understand the library's understanding of this, I may be able to try and reason about it.
- Ngôn ngữ chính
- Python
- Star
- 1.7k
- Fork
- 207
- Merge trung bình
- 4 giờ 38 phút
- Pull request đã merge (30 ngày)
- 12
Chuẩn bị môi trường
Chúng tôi chưa kiểm tra các tệp thiết lập môi trường của dự án này. Hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
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.
Issue khác của pytest-dev/pytest-asyncio
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
pytest-dev/pytest-asyncio#1475 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 56/100
pytest-dev/pytest-asyncio#1514 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
pytest-dev/pytest-asyncio#1501 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
pytest-dev/pytest-asyncio#1463 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Don't warn about `asyncio_default_fixture_loop_scope` unless the test suite uses `pytest-asyncio`Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 52/100
pytest-dev/pytest-asyncio#1344 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của pytest-dev/pytest-asyncio
Issue tương tự
-
bug status/needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
prowler-cloud/prowler#12887 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area: desktop platform: macos priority: p3 status: ready type: enhancement
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
use-agent-os/agent-os#3484 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
open-telemetry/opentelemetry-python-contrib#5113 · 2 bình luận · 2 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
external
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
langchain-ai/docs#6255 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày