mirror of
				https://github.com/open-webui/mcpo
				synced 2025-06-26 18:26:58 +00:00 
			
		
		
		
	Gracefully shutdown uvicorn.Server on task cancellation in run()
This commit is contained in:
		
							parent
							
								
									27af7a6f22
								
							
						
					
					
						commit
						101c513aeb
					
				| @ -2,6 +2,7 @@ import json | ||||
| import os | ||||
| import logging | ||||
| import socket | ||||
| import asyncio | ||||
| from contextlib import AsyncExitStack, asynccontextmanager | ||||
| from typing import Optional | ||||
| 
 | ||||
| @ -341,4 +342,9 @@ async def run( | ||||
|     ) | ||||
|     server = uvicorn.Server(config) | ||||
| 
 | ||||
|     await server.serve() | ||||
|     try: | ||||
|         await server.serve() | ||||
|     except asyncio.CancelledError: | ||||
|         server.should_exit = True | ||||
|         await server.shutdown() | ||||
|         raise  | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user