j-stew opened a new issue, #39532:
URL: https://github.com/apache/airflow/issues/39532

   ### Apache Airflow version
   
   Other Airflow 2 version (please specify below)
   
   ### If "Other Airflow 2 version" selected, which one?
   
   2.6.1
   
   ### What happened?
   
   Using sensor in reschedule mode with xcom, the xcom clears between 
reschedule checks
   
   Note: Deferrable operators not viable here due to database slowness
   
   ### What you think should happen instead?
   
   The xcom persists across sensor reschedule checks
   
   ### How to reproduce
   
   ```
   import logging
   from datetime import datetime
   
   from airflow import DAG
   from airflow.sensors.base_sensor_operator import BaseSensorOperator
   from airflow.models import XCom
   
   class TestAsyncSensor(BaseSensorOperator):
       def poke(self, context):
           number = context['ti'].xcom_pull(key="number", task_ids=self.task_id 
+ "_original", dag_id=self.dag_id)
           logging.info(
               f"Start number: {number}, Date: {context['ti'].execution_date}"
           )
           if number is None:
               number = 1
               # context['ti'].xcom_push(key="number", value=number)
           elif number < 10:
               number += 1
           else:
               return True
           XCom.set(
               key="number",
               value=number,
               task_id=self.task_id + "_original",
               dag_id=self.dag_id,
               execution_date=context['ti'].execution_date)
           logging.info(
               f"End number: {number}"
           )
           return False
   
   
   with DAG(
       "test_async_sensor",
       schedule_interval="@once",
       catchup=False,
       default_args={
           "depends_on_past": False,
           "start_date": datetime(2024, 5, 1),
       },
   ) as dag:
       ss = TestAsyncSensor(dag=dag,
                            task_id="async_sensor",
                            mode="reschedule",
                            do_xcom_push=True)
       ss
   ```
   
   ### Operating System
   
   Debian GNU/Linux 10 (buster)
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Deployment
   
   Other Docker-based deployment
   
   ### Deployment details
   
   _No response_
   
   ### Anything else?
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
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: commits-unsubscr...@airflow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to