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 <soeren-faustus.herrmann@schott.org>
This commit is contained in:
Soeren Herrmann 2025-04-14 08:39:19 +02:00 committed by GitHub
parent 0204fba918
commit bd2adaa9ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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