File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -309,12 +309,24 @@ async def shutdown_units() -> None:
309309 else :
310310 unit .shutdown () # type: ignore
311311
312- asyncio .run_coroutine_threadsafe (shutdown_units (), loop = loop ).result ()
313-
314- # for cache in MessageCache.values():
315- # cache.clear()
312+ shutdown_future = asyncio .run_coroutine_threadsafe (shutdown_units (), loop = loop )
313+ try :
314+ shutdown_future .result ()
315+ except KeyboardInterrupt :
316+ logger .warning ("Interrupted during unit shutdown. This may indicate units with slow shutdown methods."
317+ "Re-trying... Press ctrl-c again to terminate immediately." )
318+ shutdown_future .result ()
316319
317- asyncio .run_coroutine_threadsafe (context .revert (), loop = loop ).result ()
320+ revert_future = asyncio .run_coroutine_threadsafe (context .revert (), loop = loop )
321+ try :
322+ revert_future .result ()
323+ except KeyboardInterrupt :
324+ logger .warning ("Interrupted during context revert."
325+ "Re-trying... (will timeout in 10 seconds)" )
326+ try :
327+ revert_future .result (timeout = 10.0 )
328+ except TimeoutError :
329+ logger .warning ("Timed out waiting for retry on context revert" )
318330
319331 logger .debug (f"Remaining tasks in event loop = { asyncio .all_tasks (loop )} " )
320332
You can’t perform that action at this time.
0 commit comments