Browse Source

ignore CancelledError when stopping the server

Alex Cheema 10 months ago
parent
commit
2e1233357c
1 changed files with 4 additions and 1 deletions
  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):