From 063033a8c6680da49c4f8af381296b3730872ea7 Mon Sep 17 00:00:00 2001 From: Ben Clifford Date: Sat, 12 Aug 2023 14:51:38 +0200 Subject: [PATCH] Remove unused key in iteration of task dictionary (#2863) This comes from a flake8-bugbear warning. --- parsl/dataflow/dflow.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/parsl/dataflow/dflow.py b/parsl/dataflow/dflow.py index 936a32acf4..dd13b6adbd 100644 --- a/parsl/dataflow/dflow.py +++ b/parsl/dataflow/dflow.py @@ -1146,8 +1146,11 @@ def wait_for_current_tasks(self) -> None: logger.info("Waiting for all remaining tasks to complete") - items = list(self.tasks.items()) - for task_id, task_record in items: + # .values is made into a list immediately to reduce (although not + # eliminate) a race condition where self.tasks can be modified + # elsewhere by a completing task being removed from the dictionary. + task_records = list(self.tasks.values()) + for task_record in task_records: # .exception() is a less exception throwing way of # waiting for completion than .result() fut = task_record['app_fu']