diff --git a/podman_compose.py b/podman_compose.py index 32f8dfe..c7a1f56 100755 --- a/podman_compose.py +++ b/podman_compose.py @@ -2780,11 +2780,16 @@ async def compose_up(compose: PodmanCompose, args): tasks = set() async def handle_sigint(): - log.info("Caught SIGINT, shutting down...") - down_args = argparse.Namespace(**dict(args.__dict__, volumes=False)) - await compose.commands["down"](compose, down_args) - for task in tasks: - task.cancel() + log.info("Caught SIGINT or Ctrl+C, shutting down...") + try: + log.info("Shutting down gracefully, please wait...") + down_args = argparse.Namespace(**dict(args.__dict__, volumes=False)) + await compose.commands["down"](compose, down_args) + except Exception as e: + log.error(f"Error during shutdown: {e}") + finally: + for task in tasks: + task.cancel() if sys.platform != 'win32': loop = asyncio.get_event_loop()