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/03/23 05:42:27 UTC

[GitHub] [airflow] ankitdobhal commented on a change in pull request #14920: chore: Refactor code quality issues

ankitdobhal commented on a change in pull request #14920:
URL: https://github.com/apache/airflow/pull/14920#discussion_r599284089



##########
File path: airflow/sensors/smart_sensor.py
##########
@@ -672,13 +672,13 @@ def _execute_sensor_work(self, sensor_work):
 
     def flush_cached_sensor_poke_results(self):
         """Flush outdated cached sensor states saved in previous loop."""
-        for key, cached_work in self.cached_dedup_works.items():
+        for key, cached_work in self.cached_dedup_works.copy().items():

Review comment:
       Dictionaries are represented by a hash table and adding or removing items while iterating over it will alter the iteration order. This will cause a RuntimeError.
   
   If you need to add items to the dictionary during iteration, it is recommended to iterate over a shallow `copy` of the dictionary.




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