From bd2adaa9ca062c3471cfd1fa611e19f4c4a9e3dd Mon Sep 17 00:00:00 2001 From: Soeren Herrmann <33161332+PixelWelt@users.noreply.github.com> Date: Mon, 14 Apr 2025 08:39:19 +0200 Subject: [PATCH] Clean up exception handeling in cleanup_service.py (#1387) * cleaned up exception handeling in cleanup_service.py * added general exception for edge cases removed obsolete comment --------- Co-authored-by: Soeren Herrmann --- examples/services/cleanup/cleanup_service.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/examples/services/cleanup/cleanup_service.py b/examples/services/cleanup/cleanup_service.py index 5e35f483..13319790 100644 --- a/examples/services/cleanup/cleanup_service.py +++ b/examples/services/cleanup/cleanup_service.py @@ -79,15 +79,24 @@ while True: # noinspection PyBroadException try: deleted_task = Task.get_task(task_id=task.id) - deleted_task.delete( + if deleted_task.delete( delete_artifacts_and_models=True, skip_models_used_by_other_tasks=True, raise_on_error=False - ) - except Exception as ex: + ): + logging.info(f'successfully deleted task with id {task.id}') + else: + logging.warning(f'could not delete task with id {task.id}') + except ValueError as e: logging.warning( - "Could not delete Task ID={}, {}".format( - task.id, ex.message if hasattr(ex, "message") else ex + "Could not find Task ID={}, {}".format( + task.id, e.message if hasattr(e, "message") else e + ) + ) + except Exception as e: + logging.warning( + "Error while deleting Task ID={}, {}".format( + task.id, e.message if hasattr(e, "message") else e ) ) continue