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 2020/11/23 16:29:04 UTC

[GitHub] [airflow] ashb commented on a change in pull request #12530: fix dag serialization crash caused by preset DagContext

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



##########
File path: tests/serialization/test_dag_serialization.py
##########
@@ -448,6 +448,14 @@ def test_deserialization_start_date(self, dag_start_date, task_start_date, expec
         simple_task = dag.task_dict["simple_task"]
         self.assertEqual(simple_task.start_date, expected_task_start_date)
 
+    def test_deserialization_with_dag_context(self):
+        dag = DAG(dag_id='simple_dag', start_date=datetime(2019, 8, 1, tzinfo=timezone.utc))
+        DagContext.push_context_managed_dag(dag)
+        BaseOperator(task_id='simple_task')
+        # should not raise RuntimeError: dictionary changed size during iteration
+        SerializedDAG.to_dict(dag)
+        DagContext.pop_context_managed_dag()

Review comment:
       ```suggestion
           with DAG(dag_id='simple_dag', start_date=datetime(2019, 8, 1, tzinfo=timezone.utc)) as dag:
               BaseOperator(task_id='simple_task')
               # should not raise RuntimeError: dictionary changed size during iteration
               SerializedDAG.to_dict(dag)
   ```




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

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