Implementation:Apache Airflow BaseExecutor Interface
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Execution, Python_API |
| Last Updated | 2026-02-08 00:00 GMT |
Overview
Concrete tool for dispatching task execution provided by the BaseExecutor, LocalExecutor, and ExecutorLoader classes.
Description
BaseExecutor defines the abstract interface all executors must implement. LocalExecutor extends it with multiprocessing-based execution using SimpleQueue for task distribution. ExecutorLoader is a utility class that dynamically resolves and loads the configured executor by name.
Usage
Configure the executor in airflow.cfg under [core].executor. Custom executors must subclass BaseExecutor and implement the required methods.
Code Reference
Source Location
- Repository: Apache Airflow
- File: airflow-core/src/airflow/executors/base_executor.py
- Lines: L136-626
Signature
class BaseExecutor(LoggingMixin):
def __init__(
self,
parallelism: int = PARALLELISM,
team_name: str | None = None,
):
...
# Key methods:
def execute_async(self, key, command, queue=None, executor_config=None): ...
def sync(self): ...
def heartbeat(self): ...
def trigger_tasks(self, open_slots): ...
def end(self): ...
LocalExecutor:
class LocalExecutor(BaseExecutor):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Uses multiprocessing.SimpleQueue for task distribution
# Spawns worker processes up to parallelism limit
ExecutorLoader:
class ExecutorLoader:
# Maps executor names to classes
# Supports: LocalExecutor, CeleryExecutor, KubernetesExecutor, etc.
@classmethod
def _get_executor_names(cls, validate_teams: bool = True) -> list[ExecutorName]: ...
@classmethod
def load_executor(cls, executor_name: str) -> BaseExecutor: ...
Import
from airflow.executors.base_executor import BaseExecutor
from airflow.executors.local_executor import LocalExecutor
from airflow.executors.executor_loader import ExecutorLoader
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| parallelism | int | No | Max concurrent tasks (default from config) |
| team_name | str or None | No | Multi-team executor support |
| TaskInstances | Scheduled TIs | Yes | Tasks queued by the scheduler |
Outputs
| Name | Type | Description |
|---|---|---|
| event_buffer | dict[TaskInstanceKey, EventBufferValueType] | Completion states for finished tasks |
| running | set[TaskInstanceKey] | Currently executing task set |
Usage Examples
Configuration
# airflow.cfg
# [core]
# executor = LocalExecutor
# Custom executor
class MyExecutor(BaseExecutor):
def execute_async(self, key, command, queue=None, executor_config=None):
# Custom execution logic
...
def sync(self):
# Check running task status
...
Related Pages
Implements Principle
Requires Environment
Uses Heuristic
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment