ephraimbuddy commented on code in PR #47592: URL: https://github.com/apache/airflow/pull/47592#discussion_r2205314429
########## 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: I mean that the above `if hasattr` can be replaced with clear_db_runs as the first item before clear_db_dags below -- 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]
