josh-fell commented on a change in pull request #16866:
URL: https://github.com/apache/airflow/pull/16866#discussion_r686471437



##########
File path: airflow/example_dags/example_xcom.py
##########
@@ -18,50 +18,61 @@
 
 """Example DAG demonstrating the usage of XComs."""
 from airflow import DAG
-from airflow.operators.python import PythonOperator
+from airflow.operators.python import PythonOperator, get_current_context
 from airflow.utils.dates import days_ago
 
 value_1 = [1, 2, 3]
 value_2 = {'a': 'b'}
+value_3 = 'some value'
 
 
 def push(**kwargs):
     """Pushes an XCom without a specific target"""
+
+    # Using the "classic" approach
     kwargs['ti'].xcom_push(key='value from pusher 1', value=value_1)
 
+    # Using the approach available as of Airflow 2.0.  When using this 
approach, `**kwargs`
+    # is not needed to access the execution context.
+    context = get_current_context()
+    context['ti'].xcom_push(key='other value from pusher 1', value=value_2)

Review comment:
       @ashb I updated the example when using `get_current_context()`. If you 
still have some concerns, happy to nuke showing this method from the example 
DAG so we can push these updates forward.  Thanks for your feedback as always!




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to