Browse Source

ignore CancelledError when stopping the server

Alex Cheema 11 tháng trước cách đây
mục cha
commit
2e1233357c
1 tập tin đã thay đổi với 4 bổ sung1 xóa
  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):