fix: add shutdown timeout so cProfile data is written on SIGTERM

srv.wait_closed() blocked indefinitely on active relay connections,
preventing serve() from returning and prof.dump_stats() from running.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
user
2026-02-21 16:32:50 +01:00
parent 918d03cc58
commit 76dac61eb6

View File

@@ -528,7 +528,12 @@ async def serve(config: Config) -> None:
for srv in servers:
srv.close()
for srv in servers:
await srv.wait_closed()
try:
await asyncio.wait_for(srv.wait_closed(), timeout=5.0)
except TimeoutError:
pass
if metrics.active:
logger.info("shutdown: %d connections still active", metrics.active)
if api_srv:
api_srv.close()
await api_srv.wait_closed()