Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix signal handling in triggerer job runner #60190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking "Sign up for GitHub", you agree to our terms of service and privacy statement. We'll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
potiuk merged 1 commit into apache:main from astronomer:fix_signal_handling_triggerer
Jan 7, 2026
Merged

Fix signal handling in triggerer job runner #60190

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions airflow-core/src/airflow/jobs/triggerer_job_runner.py
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,13 @@ def _exit_gracefully(self, signum, frame) -> None:
self.trigger_runner.stop = True
else:
self.log.warning("Forcing exit due to second exit signal %s", signum)

self.trigger_runner.kill(signal.SIGKILL)
if self.trigger_runner:
self.trigger_runner.kill(signal.SIGKILL)
sys.exit(os.EX_SOFTWARE)

def _execute(self) -> int | None:
self.log.info("Starting the triggerer")
self.register_signals()
try:
# Kick off runner sub-process without DB access
self.trigger_runner = TriggerRunnerSupervisor.start(
Expand Down Expand Up @@ -848,7 +849,6 @@ class TriggerRunner:
failed_triggers: deque[tuple[int, BaseException | None]]

# Should-we-stop flag
# TODO: set this in a sig-int handler
stop: bool = False

# TODO: connect this to the parent process
Expand All @@ -866,8 +866,14 @@ def __init__(self):
self.failed_triggers = deque()
self.job_id = None

def _handle_signal(self, signum, frame) -> None:
"""Handle termination signals gracefully."""
self.stop = True

def run(self):
"""Sync entrypoint - just run a run in an async loop."""
"""Sync entrypoint - just run arun in an async loop."""
signal.signal(signal.SIGINT, self._handle_signal)
signal.signal(signal.SIGTERM, self._handle_signal)
asyncio.run(self.arun())

async def arun(self):
Expand Down