diff --git a/examples/blender/blender.py b/examples/blender/blender.py index 0fda1ad03..504f6c343 100755 --- a/examples/blender/blender.py +++ b/examples/blender/blender.py @@ -119,7 +119,20 @@ async def worker(ctx: WorkContext, tasks): task = loop.create_task(main(subnet_tag=args.subnet_tag)) try: loop.run_until_complete(task) - except (Exception, KeyboardInterrupt) as e: - print(e) + except KeyboardInterrupt: + print( + f"{utils.TEXT_COLOR_YELLOW}" + "Shutting down gracefully, please wait a few seconds " + "or press Ctrl+C to exit immediately..." + f"{utils.TEXT_COLOR_DEFAULT}" + ) task.cancel() - loop.run_until_complete(task) + try: + loop.run_until_complete(task) + print( + f"{utils.TEXT_COLOR_YELLOW}" + "Shutdown completed, thank you for waiting!" + f"{utils.TEXT_COLOR_DEFAULT}" + ) + except KeyboardInterrupt: + pass diff --git a/examples/yacat/yacat.py b/examples/yacat/yacat.py index 845022b86..63fdd1d66 100644 --- a/examples/yacat/yacat.py +++ b/examples/yacat/yacat.py @@ -155,7 +155,20 @@ async def worker_find_password(ctx: WorkContext, tasks): try: loop.run_until_complete(task) - except (Exception, KeyboardInterrupt) as e: - print(e) + except KeyboardInterrupt: + print( + f"{utils.TEXT_COLOR_YELLOW}" + "Shutting down gracefully, please wait a few seconds " + "or press Ctrl+C to exit immediately..." + f"{utils.TEXT_COLOR_DEFAULT}" + ) task.cancel() - loop.run_until_complete(task) + try: + loop.run_until_complete(task) + print( + f"{utils.TEXT_COLOR_YELLOW}" + "Shutdown completed, thank you for waiting!" + f"{utils.TEXT_COLOR_DEFAULT}" + ) + except KeyboardInterrupt: + pass