alligator.workers

class alligator.workers.Worker(gator, max_tasks=0, to_consume='all', nap_time=0.1, log_level=20)
check_and_run_task()

Handles the logic of checking for & executing a task.

Worker.run_forever uses this in a loop to actually handle the main logic, though you can call this on your own if you have different needs.

Returns:
True if a task was run successfully, False if there was
no task to process or executing the task failed.
Return type:bool
get_log(log_level=20)

Sets up logging for the instance.

Parameters:log_level (int) – Optional. The logging level you’d like for output. Default is logging.INFO.
Returns:The log instance.
Return type:logging.Logger
ident()

Returns a string identifier for the worker.

Used in the printed messages & includes the process ID.

interrupt()

Prints an interrupt message to stdout.

result(result)

Prints the received result from a task to stdout.

Parameters:result – The result of the task
run_forever()

Causes the worker to run either forever or until the Worker.max_tasks are reached.

starting()

Prints a startup message to stdout.

stopping()

Prints a shutdown message to stdout.