Python handlers abandoned past their deadline keep running and accumulate
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 43/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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().
- 主要言語
- Rust
- スター
- 37
- フォーク
- 8
- 平均マージ
- 14時間 16分
- マージ済み PR(30日)
- 244
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
hardbyte/awa のほかの issue
-
feature
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 18/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
メンテナーはふだん 1 日以内に返信
-
operational
難易度 5/5 1週間以上 初心者へのやさしさ 8/100
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
jelmer/buildlog-consultant#364 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
solutionscay/skiff#310 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
valkey-io/valkey-large-object#222 ·
メンテナーはふだん 1 日以内に返信
-
bug user-priority/P1
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信