Python handlers abandoned past their deadline keep running and accumulate
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
- 43/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- backend, distributed-systems
Hướng nghiên cứu
Start by reading awa-python/src/worker.rs, especially the conversion through pyo3_async_runtimes::into_future_with_locals, and trace how the Rust executor drops the handler future on abandonment and shutdown. Reproduce with a handler that awaits forever and the issue's worker and deadline settings. Done when cancellation reaches the Python handler, live coroutines stay at or below max_workers, and no handler survives shutdown.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
When a Rust runtime abandons an attempt (the handler is still running well past its deadline, after deadline + 2 × rescue interval), the executor drops the handler future, frees the worker slot and the dispatcher claims a replacement. For Python handlers that drop does not stop anything: awa-python/src/worker.rs turns the coroutine into a Rust future with pyo3_async_runtimes::into_future_with_locals, and dropping that future only drops a oneshot receiver. The asyncio task is never cancelled.
Each orphaned task keeps its Job (row and parsed args model), its coroutine frames and whatever it awaits (sockets, pooled connections). Nothing drains them, so a handler stuck on an await that never resolves (an HTTP call without a timeout, for example) leaks up to max_workers tasks per deadline-plus-grace window. If the hung await holds a pooled connection, new handlers queue on that pool and become orphans too. An orphan that wakes later can also repeat side effects for an attempt that rescue has already retried.
Reproduced with max_workers=4, deadline_duration_ms=1000 and deadline_rescue_interval_ms=200, and a handler that awaits forever: live handler coroutines grew 8 → 12 → 20 → 24 → 32 → 36 over 12 seconds, and all 36 were still running after client.shutdown().
Proposed fix: schedule the coroutine on the event loop as a task the Rust side owns (for example asyncio.run_coroutine_threadsafe, or a small helper in the Python package), and hold a drop guard that cancels it (loop.call_soon_threadsafe(task.cancel) / cancelling the concurrent future) when the Rust future is dropped, both on abandonment and on shutdown. A gauge of abandoned Python tasks still running would make the remaining cases visible.
Acceptance: with a handler that awaits forever, abandoned tasks are cancelled (the handler sees asyncio.CancelledError), the live coroutine count stays at most max_workers, and nothing survives shutdown().
- Ngôn ngữ chính
- Rust
- Star
- 37
- Fork
- 8
- Merge trung bình
- 14 giờ 16 phút
- Pull request đã merge (30 ngày)
- 244
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: 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 hardbyte/awa
-
feature
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
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 18/100
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
Maintainer thường phản hồi trong vòng 1 ngày
-
0.6.19 release checklistĐang mởoperational
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 8/100
hardbyte/awa#861 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
hardbyte/awa#841 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
Mobile release verification reports missing build inputs with a custom Cargo target directoryĐang mởbug good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
getsotto/sotto-authenticator#139 ·
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 82/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
registrystack/registry-stack#2924 ·
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 78/100
foundry-rs/starknet-foundry#4733 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100