This is an automated email from the ASF dual-hosted git repository.

amoghrajesh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new bdc7bde97be Fix leaked triggerer thread in 
test_trigger_logger_fd_closed_when_removed (#70941)
bdc7bde97be is described below

commit bdc7bde97be72baa57854cea8b09a2310a18a3bc
Author: Amogh Desai <[email protected]>
AuthorDate: Mon Aug 3 10:21:01 2026 +0530

    Fix leaked triggerer thread in test_trigger_logger_fd_closed_when_removed 
(#70941)
---
 airflow-core/tests/unit/jobs/test_triggerer_job.py | 27 +++++++++++-----------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/airflow-core/tests/unit/jobs/test_triggerer_job.py 
b/airflow-core/tests/unit/jobs/test_triggerer_job.py
index 648ecf602fa..07f861f4f91 100644
--- a/airflow-core/tests/unit/jobs/test_triggerer_job.py
+++ b/airflow-core/tests/unit/jobs/test_triggerer_job.py
@@ -1125,22 +1125,23 @@ def test_trigger_logger_fd_closed_when_removed(session):
         mock_init_log_file.return_value.open.return_value = mock_file
 
         trigger_runner_supervisor = 
TriggerRunnerSupervisor.start(job=Job(id=123456), capacity=10)
-        trigger_runner_supervisor.load_triggers()
-
-        # The 0.5s trigger must fire and its finished-trigger cleanup must run 
before the log FD is
-        # closed. How many service iterations that takes depends on real 
wall-clock timing and runner
-        # speed (_service_subprocess returns as soon as there is I/O, not 
after a full 0.1s), so poll
-        # until the close happens rather than relying on a fixed iteration 
count -- a fixed count is
-        # flaky on slow/loaded runners where the trigger has not fired yet 
within the window.
-        for _ in range(300):
-            trigger_runner_supervisor._service_subprocess(0.1)
-            if mock_file.close.called:
-                break
+        try:
+            trigger_runner_supervisor.load_triggers()
+
+            # The 0.5s trigger must fire and its finished-trigger cleanup must 
run before the log FD is
+            # closed. How many service iterations that takes depends on real 
wall-clock timing and runner
+            # speed (_service_subprocess returns as soon as there is I/O, not 
after a full 0.1s), so poll
+            # until the close happens rather than relying on a fixed iteration 
count -- a fixed count is
+            # flaky on slow/loaded runners where the trigger has not fired yet 
within the window.
+            for _ in range(300):
+                trigger_runner_supervisor._service_subprocess(0.1)
+                if mock_file.close.called:
+                    break
+        finally:
+            trigger_runner_supervisor.kill(force=False)
 
     mock_file.close.assert_called_once()
 
-    trigger_runner_supervisor.kill(force=False)
-
 
 def 
test_trigger_logger_fd_closed_when_upload_to_remote_raises(jobless_supervisor):
     """If upload_to_remote() raises during finished-trigger cleanup, the FD 
must still be closed.

Reply via email to