fix(server): close http listener cleanly on shutdown
This commit is contained in:
11
src/main.py
11
src/main.py
@@ -387,6 +387,17 @@ async def main(port=80):
|
|||||||
)
|
)
|
||||||
raise
|
raise
|
||||||
finally:
|
finally:
|
||||||
|
srv = getattr(app, "server", None)
|
||||||
|
if srv is not None:
|
||||||
|
try:
|
||||||
|
srv.close()
|
||||||
|
await srv.wait_closed()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
app.server = None
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
if shutdown_handlers_registered:
|
if shutdown_handlers_registered:
|
||||||
for sig in (signal.SIGINT, signal.SIGTERM):
|
for sig in (signal.SIGINT, signal.SIGTERM):
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user