File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
packages/service-library/src/servicelib/long_running_tasks Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 1+ import logging
2+ import traceback
13from typing import Any
24
35from .errors import TaskNotCompletedError , TaskNotFoundError
46from .models import TaskBase , TaskId , TaskStatus
57from .task import TaskContext , TasksManager , TrackedTask
68
9+ _logger = logging .getLogger (__name__ )
10+
711
812def list_tasks (
913 tasks_manager : TasksManager , task_context : TaskContext | None
@@ -35,7 +39,11 @@ async def get_task_result(
3539 return task_result
3640 except (TaskNotFoundError , TaskNotCompletedError ):
3741 raise
38- except Exception :
42+ except Exception as exc :
43+ # the task raised an exception
44+ formatted_traceback = "" .join (traceback .format_exception (exc ))
45+ _logger .info ("Task '%s' raised an exception: %s" , task_id , formatted_traceback )
46+
3947 # the task shall be removed in this case
4048 await tasks_manager .remove_task (
4149 task_id , with_task_context = task_context , reraise_errors = False
You can’t perform that action at this time.
0 commit comments