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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user