swh.scheduler.task module#

swh.scheduler.task.ts()[source]#
class swh.scheduler.task.SWHTask[source]#

Bases: Task

a schedulable task (abstract class)

Current implementation is based on Celery. See http://docs.celeryproject.org/en/latest/reference/celery.app.task.html for how to use tasks once instantiated

reject_on_worker_lost = None#

Inherited from celery.app.task.Task, but we need to override its docstring because it uses a custom ReST role

property statsd#
on_failure(exc, task_id, args, kwargs, einfo)[source]#

Error handler.

This is run by the worker when the task fails.

Parameters:
  • exc (Exception) – The exception raised by the task.

  • task_id (str) – Unique id of the failed task.

  • args (Tuple) – Original arguments for the task that failed.

  • kwargs (Dict) – Original keyword arguments for the task that failed.

  • einfo (ExceptionInfo) – Exception information.

Returns:

The return value of this handler is ignored.

Return type:

None

on_success(retval, task_id, args, kwargs)[source]#

Success handler.

Run by the worker if the task executes successfully.

Parameters:
  • retval (Any) – The return value of the task.

  • task_id (str) – Unique id of the executed task.

  • args (Tuple) – Original arguments for the executed task.

  • kwargs (Dict) – Original keyword arguments for the executed task.

Returns:

The return value of this handler is ignored.

Return type:

None

property log#
ignore_result = False#

If enabled the worker won’t store task state and return values for this task. Defaults to the task_ignore_result setting.

priority = None#

Default task priority.

rate_limit = None#

None (no rate limit), ‘100/s’ (hundred tasks a second), ‘100/m’ (hundred tasks a minute),`’100/h’` (hundred tasks an hour)

Type:

Rate limit for this task type. Examples

request_stack = <celery.utils.threads._LocalStack object>#

Task request stack, the current request will be the topmost.

run(*args, **kwargs)[source]#

The body of the task executed by workers.

serializer = 'json'#

The name of a serializer that are registered with kombu.serialization.registry. Default is ‘json’.

store_errors_even_if_ignored = False#

When enabled errors will be stored even if the task is otherwise configured to ignore results.

track_started = True#

If enabled the task will report its status as ‘started’ when the task is executed by a worker. Disabled by default as the normal behavior is to not report that level of granularity. Tasks are either pending, finished, or waiting to be retried.

Having a ‘started’ status can be useful for when there are long running tasks and there’s a need to report what task is currently running.

The application default can be overridden using the task_track_started setting.

typing = True#

Enable argument checking. You can set this to false if you don’t want the signature to be checked when calling the task. Defaults to app.strict_typing.