Skip to content

Fix ASYNC110 violation in TriggerRunner - #61760

Merged
potiuk merged 1 commit into
apache:mainfrom
Eason09053360:fix/async110-trigger-runner
Feb 15, 2026
Merged

potiuk merged 1 commit into
apache:mainfrom
Eason09053360:fix/async110-trigger-runner

Conversation

@Eason09053360

Copy link
Copy Markdown
Contributor

Fix ASYNC110 violation in TriggerRunner main loop

Replaces the while + sleep polling pattern in TriggerRunner.arun() with event-driven shutdown using anyio.Event. This eliminates the ASYNC110 linting violation and improves shutdown responsiveness.

Why is this change needed?

The previous implementation used await asyncio.sleep(1) in a while loop, which is flagged by the ASYNC110 rule as an anti-pattern. This polling approach:

  • Wastes CPU cycles checking conditions repeatedly
  • Has a 1-second delay when stopping the triggerer

What does this PR do?

  • Adds anyio.Event for signaling stop condition
  • Uses anyio.move_on_after(1) instead of asyncio.sleep(1)
  • Signals the event in _handle_signal() for immediate shutdown
  • Maintains the 1-second periodic execution for normal operation

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@Eason09053360
Eason09053360 force-pushed the fix/async110-trigger-runner branch from be15099 to 638947d Compare February 11, 2026 06:22
@henry3260

Copy link
Copy Markdown
Member

Nice one!

@SameerMesiah97 SameerMesiah97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@potiuk

potiuk commented Feb 15, 2026

Copy link
Copy Markdown
Member

Looks good!

@potiuk
potiuk merged commit 51a1b20 into apache:main Feb 15, 2026
71 checks passed
dominikhei pushed a commit to dominikhei/airflow that referenced this pull request Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants