dabla opened a new pull request, #73560: URL: https://github.com/apache/airflow/pull/73560
Every task that runs through `BaseAsyncOperator.execute` logs `DeprecationWarning: There is no current event loop` as its first line on Python 3.12 and 3.13: ``` [2026-09-22 16:34:41] INFO - Worker startup parse complete bundle_name=dags-folder bundle_version= dag_file=test_msgraph.py bundle_prepare_ms=1 dag_file_parse_ms=17 [2026-09-22 16:34:41] WARNING - There is no current event loop category=DeprecationWarning ``` The task-runner process starts without an event loop set, and the `event_loop()` helper relied on `asyncio.get_event_loop()` to create one. That is exactly the case Python deprecated in 3.12, and Python 3.14 raises `RuntimeError` there instead of creating a loop. The helper also never closed a loop that asyncio created implicitly on its behalf, because it only treated loops it created itself as its own, so that loop leaked for the rest of the process. The helper now looks up the loop already set for the thread without asking asyncio to create one. A running loop, or an open loop set by the caller, is still reused untouched; otherwise the helper owns the loop it creates and closes it on exit. This keeps the current behaviour for callers that already have a loop, removes the warning, and does not depend on the Python version. `TestEventLoop` covers loop creation and cleanup without deprecation warnings, reuse of an existing or running loop, replacement of a closed loop, and `BaseAsyncOperator.execute` with and without `execution_timeout`. Three of the new tests fail against the previous implementation. Checks run locally: `task-sdk/tests/task_sdk/bases/test_operator.py` on Python 3.10 and 3.12 (the six pre-existing errors in that module come from a missing `airflow_shared` module in the local environment and occur on `main` as well), `prek run --from-ref upstream/main --stage pre-commit` and `--stage manual` (skipping the UI asset and skill-eval hooks). --- ##### Was generative AI tooling used to co-author this PR? - [X] Yes — Claude Code (Fable 5.1) Generated-by: Claude Code (Fable 5.1) following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions) -- 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]
