Replace zmq.asyncio.Context().term() with zmq.asyncio.Context().destroy(linger=0) for immediate termination

Signed-off-by: clark <panf2333@gmail.com>
This commit is contained in:
clark 2025-01-08 21:21:16 +08:00
parent b7ffb43792
commit 897db7b93d
2 changed files with 2 additions and 2 deletions

View File

@ -34,7 +34,7 @@ async def lifespan(app: FastAPI):
yield
## close zmq context
logger.info("term zmqctx")
await app.state.zmqctx.term()
app.state.zmqctx.destroy(linger=0)
app = FastAPI(lifespan=lifespan)

View File

@ -108,7 +108,7 @@ async def serve_zmq(arg, zmq_server_port: int, app: FastAPI) -> None:
# We never get here but clean up anyhow
clients.close()
workers.close()
context.term()
context.destroy(linger=0)
def _add_shutdown_handlers(app: FastAPI, server: uvicorn.Server) -> None:
"""Adds handlers for fatal errors that should crash the server"""