Skip to main content

TraceInfo

Information about task execution.

Attributes

AttributeTypeDescription
statestringThe current execution status of the task used to determine which error handling logic to apply.
retvalany = nullThe return value or exception instance resulting from the task execution.

Constructor

Signature

def TraceInfo(
state: Any,
retval: Any = None
) - > null

Parameters

NameTypeDescription
stateAnyThe current execution state of the task.
retvalAny = NoneThe return value or exception associated with the task state.

Signature

def TraceInfo(
state: string,
retval: Any = null
)

Parameters

NameTypeDescription
statestringThe current execution state of the task, such as RETRY or FAILURE
retvalAny = nullThe return value or exception object associated with the task's current state

Methods


handle_error_state()

@classmethod
def handle_error_state(
task: [Task](../../events/state/task.md?sid=celery_events_state_task),
req: [Request](../../worker/request/request.md?sid=celery_worker_request_request),
eager: boolean = false,
call_errbacks: boolean = true
) - > ExceptionInfo

Dispatches the task to the appropriate error handler based on the current state, determining whether errors should be persisted.

Parameters

NameTypeDescription
task[Task](../../events/state/task.md?sid=celery_events_state_task)The task instance being executed
req[Request](../../worker/request/request.md?sid=celery_worker_request_request)The request object containing task metadata and arguments
eagerboolean = falseFlag indicating if the task is being executed locally in the current process
call_errbacksboolean = trueWhether to trigger error callbacks defined for the task

Returns

TypeDescription
ExceptionInfoThe exception information object generated by the specific state handler

handle_reject()

@classmethod
def handle_reject(
task: [Task](../../events/state/task.md?sid=celery_events_state_task),
req: [Request](../../worker/request/request.md?sid=celery_worker_request_request)
)

Logs an error when a task is rejected by the worker.

Parameters

NameTypeDescription
task[Task](../../events/state/task.md?sid=celery_events_state_task)The task instance that was rejected
req[Request](../../worker/request/request.md?sid=celery_worker_request_request)The request object associated with the rejected task

handle_ignore()

@classmethod
def handle_ignore(
task: [Task](../../events/state/task.md?sid=celery_events_state_task),
req: [Request](../../worker/request/request.md?sid=celery_worker_request_request)
)

Logs an error when a task execution is ignored.

Parameters

NameTypeDescription
task[Task](../../events/state/task.md?sid=celery_events_state_task)The task instance being ignored
req[Request](../../worker/request/request.md?sid=celery_worker_request_request)The request object associated with the ignored task

handle_retry()

@classmethod
def handle_retry(
task: [Task](../../events/state/task.md?sid=celery_events_state_task),
req: [Request](../../worker/request/request.md?sid=celery_worker_request_request),
store_errors: boolean = true
) - > ExceptionInfo

Handle retry exception.

Parameters

NameTypeDescription
task[Task](../../events/state/task.md?sid=celery_events_state_task)The task instance requesting a retry
req[Request](../../worker/request/request.md?sid=celery_worker_request_request)The request object containing task identity and arguments
store_errorsboolean = trueWhether to update the result backend with the retry status

Returns

TypeDescription
ExceptionInfoThe exception information containing the retry reason and traceback

handle_failure()

@classmethod
def handle_failure(
task: [Task](../../events/state/task.md?sid=celery_events_state_task),
req: [Request](../../worker/request/request.md?sid=celery_worker_request_request),
store_errors: boolean = true,
call_errbacks: boolean = true
) - > ExceptionInfo

Handle exception.

Parameters

NameTypeDescription
task[Task](../../events/state/task.md?sid=celery_events_state_task)The task instance that failed
req[Request](../../worker/request/request.md?sid=celery_worker_request_request)The request object associated with the failed task
store_errorsboolean = trueWhether to persist the failure state in the result backend
call_errbacksboolean = trueWhether to execute the task's error callback functions

Returns

TypeDescription
ExceptionInfoThe exception information containing the pickleable exception and traceback