airflow.executors.local_executor

LocalExecutor

See also

For more information on how the LocalExecutor works, take a look at the guide: Local Executor

Module Contents

Classes

LocalWorkerBase

LocalWorkerBase implementation to run airflow commands. Executes the given

LocalWorker

Local worker that executes the task.

QueuedLocalWorker

LocalWorker implementation that is waiting for tasks from a queue and will

LocalExecutor

LocalExecutor executes tasks locally in parallel.

Attributes

ExecutorWorkType

airflow.executors.local_executor.ExecutorWorkType[source]
class airflow.executors.local_executor.LocalWorkerBase(result_queue)[source]

Bases: multiprocessing.Process, airflow.utils.log.logging_mixin.LoggingMixin

LocalWorkerBase implementation to run airflow commands. Executes the given command and puts the result into a result queue when done, terminating execution.

Parameters

result_queue (queue.Queue[airflow.models.taskinstance.TaskInstanceStateType]) -- the queue to store result state

run()[source]

Method to be run in sub-process; can be overridden in sub-class

execute_work(key, command)[source]

Executes command received and stores result state in queue.

Parameters
abstract do_work()[source]

Called in the subprocess and should then execute tasks

class airflow.executors.local_executor.LocalWorker(result_queue, key, command)[source]

Bases: LocalWorkerBase

Local worker that executes the task.

Parameters
  • result_queue (queue.Queue[airflow.models.taskinstance.TaskInstanceStateType]) -- queue where results of the tasks are put.

  • key (airflow.models.taskinstance.TaskInstanceKey) -- key identifying task instance

  • command (airflow.executors.base_executor.CommandType) -- Command to execute

do_work()[source]

Called in the subprocess and should then execute tasks

class airflow.executors.local_executor.QueuedLocalWorker(task_queue, result_queue)[source]

Bases: LocalWorkerBase

LocalWorker implementation that is waiting for tasks from a queue and will continue executing commands as they become available in the queue. It will terminate execution once the poison token is found.

Parameters
  • task_queue (queue.Queue[ExecutorWorkType]) -- queue from which worker reads tasks

  • result_queue (queue.Queue[airflow.models.taskinstance.TaskInstanceStateType]) -- queue where worker puts results after finishing tasks

do_work()[source]

Called in the subprocess and should then execute tasks

class airflow.executors.local_executor.LocalExecutor(parallelism=PARALLELISM)[source]

Bases: airflow.executors.base_executor.BaseExecutor

LocalExecutor executes tasks locally in parallel. It uses the multiprocessing Python library and queues to parallelize the execution of tasks.

Parameters

parallelism (int) -- how many parallel processes are run in the executor

class UnlimitedParallelism(executor)[source]

Implements LocalExecutor with unlimited parallelism, starting one process per each command to execute.

Parameters

executor (LocalExecutor) -- the executor instance to implement.

start()[source]

Starts the executor.

execute_async(key, command, queue=None, executor_config=None)[source]

Executes task asynchronously.

Parameters
  • key (airflow.models.taskinstance.TaskInstanceKey) -- the key to identify the task instance

  • command (airflow.executors.base_executor.CommandType) -- the command to execute

  • queue (str | None) -- Name of the queue

  • executor_config (Any | None) -- configuration for the executor

sync()[source]

Sync will get called periodically by the heartbeat method.

end()[source]

This method is called when the caller is done submitting job and wants to wait synchronously for the job submitted previously to be all done.

class LimitedParallelism(executor)[source]

Implements LocalExecutor with limited parallelism using a task queue to coordinate work distribution.

Parameters

executor (LocalExecutor) -- the executor instance to implement.

start()[source]

Starts limited parallelism implementation.

execute_async(key, command, queue=None, executor_config=None)[source]

Executes task asynchronously.

Parameters
  • key (airflow.models.taskinstance.TaskInstanceKey) -- the key to identify the task instance

  • command (airflow.executors.base_executor.CommandType) -- the command to execute

  • queue (str | None) -- name of the queue

  • executor_config (Any | None) -- configuration for the executor

sync()[source]

Sync will get called periodically by the heartbeat method.

end()[source]

Ends the executor. Sends the poison pill to all workers.

start()[source]

Starts the executor

execute_async(key, command, queue=None, executor_config=None)[source]

Execute asynchronously.

sync()[source]

Sync will get called periodically by the heartbeat method.

end()[source]

Ends the executor. :return:

terminate()[source]

Terminate the executor is not doing anything.

Was this entry helpful?