1
0
forked from github/onyx

Compare commits

...

1 Commits

Author SHA1 Message Date
pablonyx
575cfa5224 fix 2025-03-27 11:16:58 -07:00

View File

@@ -505,8 +505,11 @@ async def setup_tenant(tenant_id: str) -> None:
try:
token = CURRENT_TENANT_ID_CONTEXTVAR.set(tenant_id)
# Run Alembic migrations
await asyncio.to_thread(run_alembic_migrations, tenant_id)
# Run Alembic migrations in a way that isolates it from the current event loop
# Create a new event loop for this synchronous operation
loop = asyncio.get_event_loop()
# Use run_in_executor which properly isolates the thread execution
await loop.run_in_executor(None, lambda: run_alembic_migrations(tenant_id))
# Configure the tenant with default settings
with get_session_with_tenant(tenant_id=tenant_id) as db_session: