ephraimbuddy commented on code in PR #47592:
URL: https://github.com/apache/airflow/pull/47592#discussion_r2204354512


##########
providers/amazon/tests/unit/amazon/aws/log/test_cloudwatch_task_handler.py:
##########
@@ -174,8 +176,21 @@ def test_event_to_str(self):
 
 @pytest.mark.db_test
 class TestCloudwatchTaskHandler:
+    def clear_db(self):
+        # Expunge any TaskInstance from the session before clearing DB
+        # to avoid StaleDataError when the session tries to update deleted rows
+        if hasattr(self, "ti") and self.ti:
+            from sqlalchemy.orm import object_session
+
+            session = object_session(self.ti)
+            if session:
+                session.expunge(self.ti)

Review Comment:
   why not clear runs here?: `clear_db_runs()`



-- 
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

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

Reply via email to