Proposal: handle SIGTERM by default to initiate graceful worker shutdown
I maintainer di solito rispondono entro 1 giorno
@eamsden ci sta già lavorando.
Dal 8/10/2026.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 1.2k
- Fork
- 269
- Merge medio
- 2g 7h
- PR unite (30g)
- 55
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di temporalio/sdk-python
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
temporalio/sdk-python#496 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 8/100
temporalio/sdk-python#1976 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Cloud CI Skips Nexus TestsForse di nuovo libera @tconley1428 l’ha presa 68 giorni fa e non c’è nessuna pull request aperta. Aperta
temporalio/sdk-python#1704 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Windows ARM64 wheel supportAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
temporalio/sdk-python#1592 · 8 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
temporalio/sdk-python#1578 · 2 commenti · 2 reazioni ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di temporalio/sdk-python
Issue simili
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
ianktoo/project-monitor#14 ·
-
A wrong descriptor checksum is refused with the right one, also for an xprv or WIF descriptorApertasecurity
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
btclib-org/btclib-wallet#478 ·
I maintainer di solito rispondono entro 1 giorno
-
security
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
btclib-org/btclib#2727 ·
I maintainer di solito rispondono entro 1 giorno
-
good first issue lead variant:container
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
radialmonster/orf-cleanroom#10 ·
I maintainer di solito rispondono entro 1 giorno
-
gdsa opencode: keep-alive cleanup trap fails with 'keepalive_pid: unbound variable'Forse già presa @darribas l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100