Proposal: handle SIGTERM by default to initiate graceful worker shutdown
維護者通常 1 天內回覆
@eamsden 已經在處理了。
開始於 2026年10月8日。
評估
這個 Issue 還沒有評估資料。
描述
Summary
A Temporal Python worker installs no OS signal handler by default, so when the process receives SIGTERM (Kubernetes pod stop, Cloud Run scale-down/redeploy, docker stop, systemd), the OS default disposition applies and the process is terminated immediately — before the worker can stop polling or drain in-flight work. In-flight activities are abandoned and retried server-side after their timeouts. (Python installs a handler for SIGINT but deliberately leaves SIGTERM at the OS default.)
Proposal: consider initiating the worker's existing graceful-shutdown path on SIGTERM by default (opt-out-able), so the common containerized case — stop polling → drain for graceful_shutdown_timeout → cancel — works without extra wiring.
Current workaround
loop.add_signal_handler(signal.SIGTERM, ...) to trigger await worker.shutdown() (or to exit an async with worker: block).
Precedent
The TypeScript SDK already does this: its Runtime installs handlers for SIGINT/SIGTERM/SIGQUIT/SIGUSR2 by default and calls shutdown() on every worker.
Trade-offs / open questions (why it is not already the default)
- A worker usually runs inside a larger process (HTTP server, DI host, other lifecycle). A library installing a process-global signal handler can conflict with the host application's own signal handling, so any default must be clearly opt-out-able and should no-op when a host framework already owns the signal.
- Default-on vs. an explicit opt-in flag?
- If added, match the TypeScript semantics and honor the existing grace/drain config.
Why this comes up
SIGTERM-before-SIGKILL is the standard stop protocol for Kubernetes, Cloud Run, ECS, docker stop, and systemd. Users commonly expect a worker to drain on SIGTERM without extra wiring, and it is a recurring support question (e.g. https://community.temporal.io/t/proper-way-to-shutdown-on-sigterm-sigint/5485).
One of a set of sibling issues on default SIGTERM handling across the SDKs that do not auto-handle it today (Go, Python, Java, .NET, Ruby, Rust). TypeScript already does; PHP delegates process lifecycle to RoadRunner.
- 主要語言
- Python
- 星號
- 1.2k
- 分支
- 269
- 平均合併
- 1 天 20 小時
- 30 天內合併 PR
- 60
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
temporalio/sdk-python 的其他 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 68/100
temporalio/sdk-python#496 ·
維護者通常 1 天內回覆
-
[Bug] Dropping any client stops log forwarding for every other client of the same Runtime可能已有人在做 @parbhatkapila4 今天認領。 未關閉
難度 3/5 1-2 天 新手友好度 57/100
temporalio/sdk-python#1988 ·
維護者通常 1 天內回覆
-
難度 5/5 一週以上 新手友好度 8/100
temporalio/sdk-python#1976 · 1 則留言 ·
維護者通常 1 天內回覆
-
Cloud CI Skips Nexus Tests可能重新可做 @tconley1428 於 71 天前認領,目前沒有進行中的 PR。 未關閉
temporalio/sdk-python#1704 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
難度 4/5 3-5 天 新手友好度 45/100
temporalio/sdk-python#1592 · 8 則留言 ·
維護者通常 1 天內回覆
查看 temporalio/sdk-python 的全部 Issue
相似的 Issue
-
bug good first issue
難度 2/5 1-3 小時 新手友好度 78/100
yunaremaia/proto-drift#22 ·
-
bug good first issue
難度 2/5 1-3 小時 新手友好度 82/100
yunaremaia/memwatch#96 ·
-
bug good first issue
難度 1/5 1 小時以內 新手友好度 91/100
yunaremaia/ci-gate-watch#34 ·
-
bug good first issue
難度 2/5 1-3 小時 新手友好度 85/100
yunaremaia/agent-capability-attestation#64 ·
維護者通常 1 天內回覆
-
bug good first issue
難度 1/5 1 小時以內 新手友好度 86/100
yunaremaia/agent-call-graph#43 ·
維護者通常 1 天內回覆