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


##########
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:
   yeah I see your point now. There were some iterations and I forgot to add 
`clear_db_runs` in the initial try, and added the `if hasattr` lines for 
fixing. `clear_db_runs` does that job and updated!



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