Skip to content

Instantly share code, notes, and snippets.

@chandulal
Created November 26, 2019 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chandulal/7c90e7c0ba12ec8150d9301f152a1ff0 to your computer and use it in GitHub Desktop.
Save chandulal/7c90e7c0ba12ec8150d9301f152a1ff0 to your computer and use it in GitHub Desktop.
def push_to_xcoms(*args, **kwargs):
value = "dummyValue"
kwargs['ti'].xcom_push(key="dummyKey", value=value)
def pull_from_xcoms(**kwargs):
ti = kwargs['ti']
pulled_value = ti.xcom_pull(key='dummyKey', task_ids='push_to_xcoms')
print("value=" + str(pulled_value))
push_to_xcoms_task = PythonOperator(
task_id='push_to_xcoms',
provide_context=True,
python_callable=push_to_xcoms,
dag=dag
)
pull_from_xcoms_task = PythonOperator(
task_id='pull_from_xcoms',
provide_context=True,
python_callable=pull_from_xcoms,
dag=dag
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment