Skip to content

Commit b748c26

Browse files
committed
add try-except block to handle error in case of shutdown error
Signed-off-by: Mohammad Kazemi <[email protected]>
1 parent 3973c47 commit b748c26

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

podman_compose.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -2780,11 +2780,16 @@ async def compose_up(compose: PodmanCompose, args):
27802780
tasks = set()
27812781

27822782
async def handle_sigint():
2783-
log.info("Caught SIGINT, shutting down...")
2784-
down_args = argparse.Namespace(**dict(args.__dict__, volumes=False))
2785-
await compose.commands["down"](compose, down_args)
2786-
for task in tasks:
2787-
task.cancel()
2783+
log.info("Caught SIGINT or Ctrl+C, shutting down...")
2784+
try:
2785+
log.info("Shutting down gracefully, please wait...")
2786+
down_args = argparse.Namespace(**dict(args.__dict__, volumes=False))
2787+
await compose.commands["down"](compose, down_args)
2788+
except Exception as e:
2789+
log.error(f"Error during shutdown: {e}")
2790+
finally:
2791+
for task in tasks:
2792+
task.cancel()
27882793

27892794
if sys.platform != 'win32':
27902795
loop = asyncio.get_event_loop()

0 commit comments

Comments
 (0)