Skip to content

Commit

Permalink
[FIX] fastapi: Graceful shutdown of event loop
Browse files Browse the repository at this point in the history
On server shutdown, ensure that created the event loops are closed properly.
  • Loading branch information
lmignon committed Jan 10, 2025
1 parent 8c090cd commit 2db95d5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fastapi/pools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from .event_loop import EventLoopPool
from .fastapi_app import FastApiAppPool
from odoo.service.server import CommonServer

event_loop_pool = EventLoopPool()
fastapi_app_pool = FastApiAppPool()


CommonServer.on_stop(event_loop_pool.shutdown)

__all__ = ["event_loop_pool", "fastapi_app_pool"]

0 comments on commit 2db95d5

Please sign in to comment.