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

ephraimanierobi pushed a commit to branch v2-7-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit 690f3f121699c79dbbd293590d820815a10ba3b1
Author: Jarek Potiuk <[email protected]>
AuthorDate: Tue Aug 8 17:02:10 2023 +0200

    Cleanup all sqlalchemy sessions before each test (#33190)
    
    Attempt to solve some of the flakiness we saw recently - this
    change will run closing all opened sqlalchemy sessions before each
    test. This should be a little slower than before - especially
    for the very fast tests, but it provide us with much better
    isolation between the tests - thus avoiding the flakiness
    that we observe recently - as documented in #33178
    
    Hopefully this one
    
    Fixes: #33178
    (cherry picked from commit 515179fe67c0c6bd8b693c5ab313f4a0cfbacea7)
---
 tests/conftest.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tests/conftest.py b/tests/conftest.py
index 49733a7da4..2b431f1772 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -942,3 +942,12 @@ def initialize_providers_manager():
     from airflow.providers_manager import ProvidersManager
 
     ProvidersManager().initialize_providers_configuration()
+
+
[email protected](autouse=True, scope="function")
+def close_all_sqlalchemy_sessions():
+    from sqlalchemy.orm import close_all_sessions
+
+    close_all_sessions()
+    yield
+    close_all_sessions()

Reply via email to