From 3734e683e1719d9f6abe9e80e475a4c2c275cdaf Mon Sep 17 00:00:00 2001 From: pablodanswer Date: Thu, 7 Nov 2024 10:25:22 -0800 Subject: [PATCH] ensure proper attribution --- backend/danswer/db/engine.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/danswer/db/engine.py b/backend/danswer/db/engine.py index e2204cdabc7..639f6addc75 100644 --- a/backend/danswer/db/engine.py +++ b/backend/danswer/db/engine.py @@ -323,12 +323,14 @@ async def get_async_session_with_tenant( yield session +@contextmanager def get_session_with_default_tenant() -> Generator[Session, None, None]: """ Get a database session using the current tenant ID from the context variable. """ tenant_id = CURRENT_TENANT_ID_CONTEXTVAR.get() - return get_session_with_tenant(tenant_id) + with get_session_with_tenant(tenant_id) as session: + yield session @contextmanager