You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/06/29 07:55:20 UTC

[GitHub] [airflow] ashb commented on a change in pull request #16701: Remove duplicated try, there is already a try in provide_session

ashb commented on a change in pull request #16701:
URL: https://github.com/apache/airflow/pull/16701#discussion_r660370386



##########
File path: airflow/models/dag.py
##########
@@ -2405,22 +2405,18 @@ def deactivate_deleted_dags(cls, alive_dag_filelocs: List[str], session=None):
         log.debug("Deactivating DAGs (for which DAG files are deleted) from %s table ", cls.__tablename__)
 
         dag_models = session.query(cls).all()
-        try:
-            for dag_model in dag_models:
-                if dag_model.fileloc is not None:
-                    if correct_maybe_zipped(dag_model.fileloc) not in alive_dag_filelocs:
-                        dag_model.is_active = False
-                    else:
-                        # If is_active is set as False and the DAG File still exists
-                        # Change is_active=True
-                        if not dag_model.is_active:
-                            dag_model.is_active = True
+        for dag_model in dag_models:
+            if dag_model.fileloc is not None:
+                if correct_maybe_zipped(dag_model.fileloc) not in alive_dag_filelocs:
+                    dag_model.is_active = False
                 else:
-                    continue
-            session.commit()
-        except Exception:
-            session.rollback()
-            raise
+                    # If is_active is set as False and the DAG File still exists
+                    # Change is_active=True
+                    if not dag_model.is_active:
+                        dag_model.is_active = True
+            else:
+                continue
+        session.commit()

Review comment:
       ```suggestion
   ```
   
   https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#database-session-handling
   
   (I know you didn't change this, but lets correct it while we are changing the line anyway.)




-- 
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-unsubscribe@airflow.apache.org

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