selinon.executor.celery_mocks module

Injected Celery related implementations of methods.

Classes and functions to make Selinon executor work as a standalone CLI.

class selinon.executor.celery_mocks.SimulateAsyncResult(node_name, node_id)[source]

Bases: object

Simulate AsyncResult returned by apply_async() or by instantiating AsyncResult by Task id.

failed()[source]

Check for failure.

Returns:True if task failed
result

Get result of a task.

Returns:retrieve result of the task or exception that was raised
classmethod set_failed(task_id, exception)[source]

Mark task as failed after run - called by executor.

Parameters:
  • task_id – an ID of task that should be marked as failed
  • exception – exception raised in task
classmethod set_successful(task_id, result)[source]

Mark task as successful after run - called by executor.

Parameters:
  • task_id – an ID of task that should be marked as successful
  • result – result of task (None for SelinonTaskEnvelope, JSON describing system state for Dispatcher)
successful()[source]

Check for success.

Returns:True if task succeeded.
task_failures = {}
task_successes = {}
traceback

Traceback as returned by Celery’s AsyncResult.

Returns:traceback returned by a task
class selinon.executor.celery_mocks.SimulateRequest(instance)[source]

Bases: object

Simulate Celery’s Task.request.

Make possible to query task id right inside task by calling self.request.id

exception selinon.executor.celery_mocks.SimulateRetry(instance, **celery_kwargs)[source]

Bases: Exception

Simulate Celery Retry exception raised by self.retry().

selinon.executor.celery_mocks.simulate_apply_async(instance, **celery_kwargs)[source]

Simulate CeleryTask().apply_async() implementation for scheduling tasks.

Parameters:
  • instance – instance that should be scheduled
  • celery_kwargs – kwargs supplied to Celery Task (also carry arguments for Selinon)
selinon.executor.celery_mocks.simulate_retry(instance, **celery_kwargs)[source]

Simulate Celery self.retry() implementation for retrying tasks.

Parameters:
  • instance – instance that should called self.retry()
  • celery_kwargs – kwargs that will be supplied to Celery Task (also carry arguments for Selinon)