瀏覽代碼

ignore CancelledError when stopping the server

Alex Cheema 11 月之前
父節點
當前提交
2e1233357c
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      main.py

+ 4 - 1
main.py

@@ -120,7 +120,10 @@ async def shutdown(signal, loop):
     [task.cancel() for task in server_tasks]
     print(f"Cancelling {len(server_tasks)} outstanding tasks")
     await asyncio.gather(*server_tasks, return_exceptions=True)
-    await server.stop()
+    try:
+        await server.stop()
+    except CancelledError:
+        pass
     loop.stop()
 
 async def run_model_cli(node: Node, inference_engine: InferenceEngine, model_name: str, prompt: str):