You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by as...@apache.org on 2026/10/15 12:27:17 UTC

(airflow) branch main updated: Fix flaky in-process Execution API transport lifecycle test on MySQL (#74785)

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

ashb 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 5a6ab34fd51 Fix flaky in-process Execution API transport lifecycle test on MySQL (#74785)
5a6ab34fd51 is described below

commit 5a6ab34fd51dd982dbf62f5c32449d74c4aa0459
Author: Andrew Chang <69...@users.noreply.github.com>
AuthorDate: Thu Oct 15 20:27:09 2026 +0800

    Fix flaky in-process Execution API transport lifecycle test on MySQL (#74785)
    
    On MySQL the test intermittently found the loop thread still alive.
    An earlier test leaves aiomysql connections bound to a closed
    TestClient loop. When GC finalizes one while this test builds the
    app, the connection's __del__ raises inside pydantic's except block,
    and pytest keeps that error. Its __context__ traceback holds the
    frames that built the transport, so dropping the transport never ran
    the finalizer that stops the loop.
---
 airflow-core/tests/unit/api_fastapi/execution_api/test_app.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/airflow-core/tests/unit/api_fastapi/execution_api/test_app.py b/airflow-core/tests/unit/api_fastapi/execution_api/test_app.py
index ee245abbc10..11c056410e4 100644
--- a/airflow-core/tests/unit/api_fastapi/execution_api/test_app.py
+++ b/airflow-core/tests/unit/api_fastapi/execution_api/test_app.py
@@ -236,6 +236,10 @@ def test_in_process_execution_api_transport_lifecycle():
     left every later request hanging on a stopped loop. Dropping the transport must stop the loop and
     join the daemon thread (the a2wsgi background-thread leak guard).
     """
+    # Collect earlier tests' garbage first. If GC runs a failing __del__ (an aiomysql connection on a closed loop)
+    # while the app below is built, pytest keeps that error, and its __context__ chain holds the app-building
+    # frames, which keep the transport alive.
+    gc.collect()
     before = {t for t in threading.enumerate() if t.name == "InProcessExecutionAPI-loop"}
 
     api = InProcessExecutionAPI()