Proposal: handle SIGTERM by default to initiate graceful worker shutdown
Les mainteneurs répondent en général sous 1 jour
@eamsden y travaille déjà.
Depuis le 8/10/2026.
Évaluation
Cette issue n'a pas encore été évaluée.
Description
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.
- Langage dominant
- Python
- Étoiles
- 1.2k
- Forks
- 269
- Merge moyen
- 1 j 21 h
- PR mergées (30 j)
- 56
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de temporalio/sdk-python
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
temporalio/sdk-python#496 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 3/5 1-2 jours Accessibilité débutants 57/100
temporalio/sdk-python#1988 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 8/100
temporalio/sdk-python#1976 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Cloud CI Skips Nexus TestsPeut-être à nouveau libre @tconley1428 l’a pris il y a 70 jours, et aucune pull request n’est ouverte. Ouverte
temporalio/sdk-python#1704 · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
-
Windows ARM64 wheel supportOuverte
Difficulté 4/5 3-5 jours Accessibilité débutants 45/100
temporalio/sdk-python#1592 · 8 commentaires ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de temporalio/sdk-python
Issues similaires
-
idxmax/idxmin raise ValueError when a single partition is all-NAPeut-être pris @Jason10191019999 l’a pris aujourd’hui. Ouverteneeds triage
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 3 jours
-
Old versions of datamodelsOuvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 64/100
-
[BUG]: Windows GUI package of v1.17.0-rc3 has no GTK DLLsPeut-être pris @andrut-ds l’a pris aujourd’hui. Ouvertebug CI/CD Pactus-GUI Windows
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
pactus-project/pactus#2428 ·
Les mainteneurs répondent en général sous 1 jour
-
DiskDataset.reshard() can hang with a zero or negative shard sizePeut-être pris @Programmer-Develops l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 19 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
GNS3/gns3-server#3017 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour