chore(src): 🔧 refactor core logic in main.py for improved performance and bug resolution

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
Lilith 2026-02-15 09:04:17 -08:00
parent 4243aadec4
commit 1128f25cee

View file

@ -348,8 +348,15 @@ async def create_app():
),
)
# Initialize app at module level for uvicorn string loading
app = asyncio.run(create_app())
# Initialize app at module level for uvicorn string loading.
# asyncio.run() fails when uvicorn already has a running event loop (uvloop),
# so fall back to a temporary loop for synchronous module-level initialization.
try:
app = asyncio.run(create_app())
except RuntimeError:
_loop = asyncio.new_event_loop()
app = _loop.run_until_complete(create_app())
_loop.close()
# Apply logging route class to all routes
app.router.route_class = LoggingRoute