From 42460fa7f979732d9cdde7248a60cd79c99f6e49 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 30 Jan 2025 21:55:01 +0000 Subject: [PATCH] fix: create new connection per thread in SQLite test Co-Authored-By: Chris Weaver --- backend/tests/unit/onyx/db/test_users.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/tests/unit/onyx/db/test_users.py b/backend/tests/unit/onyx/db/test_users.py index 60c06296a7b..7dbf3721d76 100644 --- a/backend/tests/unit/onyx/db/test_users.py +++ b/backend/tests/unit/onyx/db/test_users.py @@ -13,9 +13,10 @@ def _call_parallel(engine, email_list: List[str]) -> None: - # Create a new session for each thread to handle SQLite's threading restrictions + # Create a new connection and session for each thread to handle SQLite's threading restrictions + connection = engine.connect() SessionLocal = sessionmaker( - bind=engine, + bind=connection, expire_on_commit=False, autoflush=True, ) @@ -27,6 +28,7 @@ def _call_parallel(engine, email_list: List[str]) -> None: raise finally: session.close() + connection.close() @pytest.mark.parametrize(