This document describes Celery 2.5. For development docs, go here.

celery.worker.job

celery.worker.job

This module defines the Request class, which specifies how tasks are executed.

copyright:
  1. 2009 - 2012 by Ask Solem.
license:

BSD, see LICENSE for more details.

class celery.worker.job.Request(body, on_ack=<function noop at 0x9af4e64>, hostname=None, logger=None, eventer=None, app=None, connection_errors=None, request_dict=None, delivery_info=None, task=None, **opts)

A request for task execution.

acknowledge()

Acknowledge task.

acknowledged
app
args
connection_errors
delivery_info
error_msg = ' Task %(name)s[%(id)s] raised exception: %(exc)s\n '

Format string used to log task failure.

eta
eventer
execute(loglevel=None, logfile=None)

Execute the task in a trace_task().

Parameters:
  • loglevel – The loglevel used by the task.
  • logfile – The logfile used by the task.
execute_using_pool(pool, loglevel=None, logfile=None)

Like execute(), but using a worker pool.

Parameters:
  • pool – A multiprocessing.Pool instance.
  • loglevel – The loglevel used by the task.
  • logfile – The logfile used by the task.
expires
extend_with_default_kwargs(loglevel, logfile)

Extend the tasks keyword arguments with standard task arguments.

Currently these are logfile, loglevel, task_id, task_name, task_retries, and delivery_info.

See celery.task.base.Task.run() for more information.

Magic keyword arguments are deprecated and will be removed in version 3.0.

classmethod from_message(message, body, **kwargs)
hostname
id
info(safe=False)
internal_error_msg = ' Task %(name)s[%(id)s] INTERNAL ERROR: %(exc)s\n '

Format string used to log internal error.

kwargs
logger
maybe_expire()

If expired, mark the task as revoked.

name
on_accepted(pid, time_accepted)

Handler called when task is accepted by worker pool.

on_ack
on_failure(exc_info)

Handler called if the task raised an exception.

on_retry(exc_info)

Handler called if the task should be retried.

on_success(ret_value, now=None)

Handler called if the task was successfully processed.

on_timeout(soft, timeout)

Handler called if the task times out.

repr_result(result, maxlen=46)
request_dict
retry_msg = 'Task %(name)s[%(id)s] retry: %(exc)s'

Format string used to log task retry.

revoked()

If revoked, skip task and mark state.

send_event(type, **fields)
shortinfo()
store_errors
success_msg = ' Task %(name)s[%(id)s] succeeded in %(runtime)ss: %(return_value)s\n '

Format string used to log task success.

task
task_id
task_name
terminate(pool, signal=None)
time_start
tzlocal
worker_pid
class celery.worker.job.TaskRequest(name, id, args=(), kwargs={}, eta=None, expires=None, **options)
celery.worker.job.execute_and_trace(name, uuid, args, kwargs, request=None, **opts)

This is a pickleable method used as a target when applying to pools.

It’s the same as:

>>> trace_task(name, *args, **kwargs)[0]

Previous topic

celery.worker.consumer

Next topic

celery.worker.mediator

This Page