title: Custom Operator XCom during run time in Airflow
body: <p>I understand for <code>PythonOperator/BashOperator</code> we can use Xcom to communicate.</p>
  
  <p>e.g. </p>
  
  <pre><code>def func(**context):
      context['task_instance'].xcom_pull()
  </code></pre>
  
  <p>However, I am wondering how to access <code>xcom</code> for a custom operator during run time.</p>
  
  <p>My operator looks like this:</p>
  
  <pre><code>class ECHOXOperator(BaseOperator):
      @apply_defaults
      def __init__(self, x, *args, **kwargs):
          self.x = x
          super(ECHOXOperator, self).__init__(*args, **kwargs)
  
      def execute(self, context):
          print(self.x)
  </code></pre>
  
  <p>So in my DAG:</p>
  
  <p>I can do </p>
  
  <pre><code>task2 = ECHOXOperator(x = 'Hello")
  </code></pre>
  
  <p>And it works well. But how can I access x from an upstream task?</p>
  
  <p>Something like:</p>
  
  <pre><code>def task1(**context):
      task_instance = context['task_instance']
      task_instance.xcom_push(key="x", value="Hello")
  
  generate_data = PythonOperator(
      task_id="task1",
      python_callable=task1,
      dag=dag,
  )
  
  task2 = ECHOXOperator(x = task_instance.xcom_pull('task1', 'x'), provide_context=True)
  
  task1 &gt;&gt; task2
  </code></pre>
  
  <p>This is not working because <code>task_instance</code> in <code>ECHOXOperator</code> is not defined.</p>
  
  <p>Thanks</p>