magpie.task.monitor

Module Contents

Classes

EventsMonitor

Events monitoring thread that captures events from the Celery worker cluster and acts upon those, in particular this will call the registered callbacks to be executed on tasks completion.

Functions

start_task_monitoring_thread

Start a monitoring thread that will inspect the celery workers and notify back the app when tasks have finished processing, along with their results.

add_task

wait_for_tasks_completion

Blocking wait for tasks to complete.

stop_task_monitoring_thread

Stop the task monitoring thread.

Data

pending_tasks

Dict of tasks that have been submitted with a callback to be executed with the result when the corresponding task finishes.

all_tasks_complete

threading.Event that signals when all tasks have been completed.

monitoring_thread

Global monitoring thread object.

API

magpie.task.monitor.pending_tasks

None

Dict of tasks that have been submitted with a callback to be executed with the result when the corresponding task finishes.

magpie.task.monitor.all_tasks_complete

‘Event(…)’

threading.Event that signals when all tasks have been completed.

magpie.task.monitor.monitoring_thread

None

Global monitoring thread object.

magpie.task.monitor.start_task_monitoring_thread()[source]

Start a monitoring thread that will inspect the celery workers and notify back the app when tasks have finished processing, along with their results.

magpie.task.monitor.add_task(task_id, callback)[source]
magpie.task.monitor.wait_for_tasks_completion(timeout=None)[source]

Blocking wait for tasks to complete.

magpie.task.monitor.stop_task_monitoring_thread()[source]

Stop the task monitoring thread.

class magpie.task.monitor.EventsMonitor[source]

Bases: threading.Thread

Events monitoring thread that captures events from the Celery worker cluster and acts upon those, in particular this will call the registered callbacks to be executed on tasks completion.

Initialization

This constructor should always be called with keyword arguments. Arguments are:

group should be None; reserved for future extension when a ThreadGroup class is implemented.

target is the callable object to be invoked by the run() method. Defaults to None, meaning nothing is called.

name is the thread name. By default, a unique name is constructed of the form “Thread-N” where N is a small decimal number.

args is a list or tuple of arguments for the target invocation. Defaults to ().

kwargs is a dictionary of keyword arguments for the target invocation. Defaults to {}.

If a subclass overrides the constructor, it must make sure to invoke the base class constructor (Thread.init()) before doing anything else to the thread.

run()[source]
on_success(event)[source]
on_error(event)[source]
trace_other_events(event)[source]