Skip to content

Commit 1f7d17e

Browse files
lmignonlembregtse
authored andcommitted
[FIX] fastapi: Graceful shutdown of event loop
On server shutdown, ensure that created the event loops are closed properly.
1 parent 457751d commit 1f7d17e

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

fastapi/pools/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
from .event_loop import EventLoopPool
22
from .fastapi_app import FastApiAppPool
3+
from odoo.service.server import CommonServer
34

45
event_loop_pool = EventLoopPool()
56
fastapi_app_pool = FastApiAppPool()
67

8+
9+
CommonServer.on_stop(event_loop_pool.shutdown)
10+
711
__all__ = ["event_loop_pool", "fastapi_app_pool"]

0 commit comments

Comments
 (0)