Airflow Xcom Exclusive May 2026
When a task pushes a value via task_instance.xcom_push() or by returning a value (the implicit push), Airflow serializes it (using JSON or a custom serializer) and stores it in the xcom table of the Airflow metadata database. Another task pulls it with task_instance.xcom_pull().
# Task A: Push
def push_task(**context):
return "data": [1, 2, 3], "user": "admin"
XComs are a mechanism for passing arbitrary data between tasks.
XCom rows are uniquely identified by this combination of columns in Airflow database: airflow xcom exclusive
Implication: XComs are scoped to a specific DAG run and task instance; different execution_date/run_id or task_id isolates them.
from airflow.models.xcom import BaseXCom
from airflow.exceptions import AirflowException
class ExclusiveXCom(BaseXCom):
ALLOWED_PULLS =
("dag_etl", "extract", "load"): ["rows_count"],
("dag_etl", "transform", "report"): ["aggregated_metrics"],
When a task pushes a value via task_instance
@classmethod
def get_value(cls, key, dag_id, task_id, run_id, map_index):
# Enforce exclusive pull: only if (dag_id, calling_task, target_task) is allowed
calling_task = task_id # Note: in real implementation, you'd need to resolve caller
allowed_keys = cls.ALLOWED_PULLS.get((dag_id, calling_task), [])
if key not in allowed_keys:
raise AirflowException(
f"XCom exclusive violation: Task calling_task not allowed to pull key 'key'"
)
return super().get_value(key, dag_id, task_id, run_id, map_index)
Author’s Note: Have you implemented exclusive XCom patterns in your own Airflow deployment? Share your experience in the comments below or reach out via the Airflow Slack (channel #xcom-exclusive).