app.trace

Trace task execution.

This module defines how the task execution is traced: errors are recorded, handlers are applied and so on.

Module Contents

Classes

TraceInfo(self,state,retval=None) Information about task execution.

Functions

info(fmt,context) Log ‘fmt % context’ with severity ‘INFO’.
task_has_custom(task,attr) Return true if the task overrides attr.
get_log_policy(task,einfo,exc)
get_task_name(request,default) Use ‘shadow’ in request for the task name if applicable.
build_tracer(name,task,loader=None,hostname=None,store_errors=True,Info=TraceInfo,eager=False,propagate=False,app=None,monotonic=monotonic,trace_ok_t=trace_ok_t,IGNORE_STATES=IGNORE_STATES) Return a function that traces task execution.
trace_task(task,uuid,args,kwargs,request=dict,**opts) Trace task execution.
_trace_task_ret(name,uuid,request,body,content_type,content_encoding,loads=loads_message,app=None,**extra_request)
_fast_trace_task(task,uuid,request,body,content_type,content_encoding,loads=loads_message,_loc=_localized,hostname=None,**_)
report_internal_error(task,exc)
setup_worker_optimizations(app,hostname=None) Setup worker related optimizations.
reset_worker_optimizations() Reset previously configured optimizations.
_install_stack_protection()
info(fmt, context)

Log ‘fmt % context’ with severity ‘INFO’.

‘context’ is also passed in extra with key ‘data’ for custom handlers.

task_has_custom(task, attr)

Return true if the task overrides attr.

get_log_policy(task, einfo, exc)
get_task_name(request, default)

Use ‘shadow’ in request for the task name if applicable.

class TraceInfo(state, retval=None)

Information about task execution.

__init__(state, retval=None)
handle_error_state(task, req, eager=False, call_errbacks=True)
handle_reject(task, req, **kwargs)
handle_ignore(task, req, **kwargs)
handle_retry(task, req, store_errors=True, **kwargs)

Handle retry exception.

handle_failure(task, req, store_errors=True, call_errbacks=True)

Handle exception.

_log_error(task, req, einfo)
build_tracer(name, task, loader=None, hostname=None, store_errors=True, Info=TraceInfo, eager=False, propagate=False, app=None, monotonic=monotonic, trace_ok_t=trace_ok_t, IGNORE_STATES=IGNORE_STATES)

Return a function that traces task execution.

Catches all exceptions and updates result backend with the state and result.

If the call was successful, it saves the result to the task result backend, and sets the task status to “SUCCESS”.

If the call raises @Retry, it extracts the original exception, uses that as the result and sets the task state to “RETRY”.

If the call results in an exception, it saves the exception as the task result, and sets the task state to “FAILURE”.

Return a function that takes the following arguments:

param uuid:The id of the task.
param args:List of positional args to pass on to the function.
param kwargs:Keyword arguments mapping to pass on to the function.
keyword request:
 Request dict.
trace_task(task, uuid, args, kwargs, request=dict, **opts)

Trace task execution.

_trace_task_ret(name, uuid, request, body, content_type, content_encoding, loads=loads_message, app=None, **extra_request)
_fast_trace_task(task, uuid, request, body, content_type, content_encoding, loads=loads_message, _loc=_localized, hostname=None, **_)
report_internal_error(task, exc)
setup_worker_optimizations(app, hostname=None)

Setup worker related optimizations.

reset_worker_optimizations()

Reset previously configured optimizations.

_install_stack_protection()