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:
parent
4243aadec4
commit
1128f25cee
1 changed files with 9 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue