🚀 We are hiring! See open positions

Airflow Xcom Exclusive !exclusive! < 2027 >

Use these strategies depending on your requirement:

In Apache Airflow, (short for "cross-communication") is the primary mechanism for tasks to share small pieces of data within a DAG run. Unlike global Variables , which are designed for static configuration, XComs are tied to specific task instances and the lifecycle of a single execution. Core Functionality: Push & Pull

The keyword "exclusive" in the context of XCom is not an official Airflow term, but it encapsulates several important characteristics that make XCom a unique and mechanism for data exchange. airflow xcom exclusive

# Task A and Task B run in parallel task_a >> task_c task_b >> task_c

In this example, consumer_task implicitly pulls the exact return value of producer_task . This creates a direct, exclusive dependency. 2. Traditional Operators (xcom_push/xcom_pull) Use these strategies depending on your requirement: In

To maintain database hygiene, implement a dedicated maintenance DAG that runs weekly to purge old XCom records:

Specify the location in your cloud bucket where XComs will be stored. The format is <connection id>@<bucket name>/<path> . # Task A and Task B run in

def task_a(**context): context['ti'].xcom_push(key=f"result_context['ti'].task_id", value=100)

from datetime import datetime from airflow import DAG from airflow.operators.python import PythonOperator def push_metadata(**kwargs): # Manually pushing an exclusive key kwargs['ti'].xcom_push(key='exclusive_status', value='ready_for_processing') # Automatically pushing to 'return_value' via return return "batch_id_99482" def pull_metadata(**kwargs): ti = kwargs['ti'] # Pulling the return_value fetched_id = ti.xcom_pull(task_ids='producer_task', key='return_value') # Pulling the custom key fetched_status = ti.xcom_pull(task_ids='producer_task', key='exclusive_status') print(f"Processing fetched_id with status: fetched_status") with DAG( dag_id='classic_xcom_example', start_date=datetime(2026, 1, 1), schedule=None, catchup=False ) as dag: producer = PythonOperator( task_id='producer_task', python_callable=push_metadata ) consumer = PythonOperator( task_id='consumer_task', python_callable=pull_metadata ) producer >> consumer Use code with caution. 2. The Modern Approach (TaskFlow API)

Implication: XComs are scoped to a specific DAG run and task instance; different execution_date/run_id or task_id isolates them.