hrithiksaini99 commented on code in PR #76322:
URL: https://github.com/apache/airflow/pull/76322#discussion_r4454723701


##########
airflow-core/tests/unit/jobs/test_triggerer_job.py:
##########
@@ -1741,6 +1742,23 @@ async def 
test_cancel_triggers_uses_distinct_messages_for_user_action_and_reassi
         assert not trigger_runner.to_cancel
         assert not trigger_runner.to_release
 
+    @pytest.mark.asyncio
+    async def test_cancel_triggers_is_idempotent_across_state_syncs(self) -> 
None:
+        """A repeated cancel from the next state sync must not interrupt a 
running on_kill()."""
+        trigger_runner = TriggerRunner()
+        task = MagicMock(spec=asyncio.Task)
+        trigger_runner.triggers = {1: {"task": task, "is_watcher": False, 
"name": "user", "events": 0}}
+
+        trigger_runner.to_cancel.append(1)
+        await trigger_runner.cancel_triggers()
+        # run_trigger() marks the trigger as soon as it enters the on_kill() 
branch.
+        trigger_runner.triggers[1]["on_kill_started"] = True

Review Comment:
   Updated! Because `cancel_triggers()` now sets 
`details["cancellation_started"] = True` directly during queue processing, the 
test now asserts against the real runner behavior rather than manually 
injecting the flag, verifying idempotency across multiple state sync passes for 
both `to_cancel` and `to_release`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to