fix(ci): handle event loop closed during test teardown

Catch RuntimeError in admin_session teardown cleanup — the event loop
may be closed when the last test's fixtures are torn down.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jason Staack
2026-03-15 06:34:57 -05:00
parent 6393945505
commit 0c0ca44084

View File

@@ -182,9 +182,12 @@ async def admin_session(admin_engine) -> AsyncGenerator[AsyncSession, None]:
try:
yield session
finally:
if existing_tables:
await session.execute(text(f"TRUNCATE {tables_csv} CASCADE"))
await session.commit()
try:
if existing_tables:
await session.execute(text(f"TRUNCATE {tables_csv} CASCADE"))
await session.commit()
except RuntimeError:
pass # Event loop may be closed during final teardown
await session.close()