Skip to content

Commit 04175d4

Browse files
committed
for shutdown_units and context.revert, only swallow one SIGINT.
1 parent 8168425 commit 04175d4

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

src/ezmsg/core/backendprocess.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -310,23 +310,23 @@ async def shutdown_units() -> None:
310310
unit.shutdown() # type: ignore
311311

312312
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-
...
313+
try:
314+
shutdown_future.result(timeout=10.0)
315+
except KeyboardInterrupt:
316+
shutdown_future.result()
317+
except TimeoutError:
318+
logger.warning("Timed out waiting for unit shutdown")
319319

320320
# for cache in MessageCache.values():
321321
# cache.clear()
322322

323323
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-
...
324+
try:
325+
revert_future.result(timeout=10.0)
326+
except KeyboardInterrupt:
327+
revert_future.result()
328+
except TimeoutError:
329+
logger.warning("Timed out waiting for context revert")
330330

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

0 commit comments

Comments
 (0)