Skip to content

Commit 8168425

Browse files
committed
Wrap shutdown_units().result() and context.revert().result() with while True: try...except KeyboardInterrupt — the same pattern already used for the stop barrier. This ensures SIGINT can't skip context.revert(), which is what cancels the pub/sub internal tasks.
1 parent 0174559 commit 8168425

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

src/ezmsg/core/backendprocess.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff 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()
312+
shutdown_future = asyncio.run_coroutine_threadsafe(shutdown_units(), loop=loop)
313+
while True:
314+
try:
315+
shutdown_future.result()
316+
break
317+
except KeyboardInterrupt:
318+
...
313319

314320
# for cache in MessageCache.values():
315321
# cache.clear()
316322

317-
asyncio.run_coroutine_threadsafe(context.revert(), loop=loop).result()
323+
revert_future = asyncio.run_coroutine_threadsafe(context.revert(), loop=loop)
324+
while True:
325+
try:
326+
revert_future.result()
327+
break
328+
except KeyboardInterrupt:
329+
...
318330

319331
logger.debug(f"Remaining tasks in event loop = {asyncio.all_tasks(loop)}")
320332

0 commit comments

Comments
 (0)