From bc67a64d2a2eada924160c833e57b8562a0e8720 Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Thu, 5 May 2022 12:10:21 +0300 Subject: [PATCH] Fix WeightsFileHandler add_callback is not multi-thread protected --- clearml/binding/frameworks/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/clearml/binding/frameworks/__init__.py b/clearml/binding/frameworks/__init__.py index fb2fc65e..97125987 100644 --- a/clearml/binding/frameworks/__init__.py +++ b/clearml/binding/frameworks/__init__.py @@ -179,7 +179,7 @@ class WeightsFileHandler(object): model=None, upload_filename=None, local_model_path=local_model_path, local_model_id=filepath, framework=framework, task=task) # call pre model callback functions - for cb in WeightsFileHandler._model_pre_callbacks.values(): + for cb in list(WeightsFileHandler._model_pre_callbacks.values()): # noinspection PyBroadException try: model_info = cb(WeightsFileHandler.CallbackType.load, model_info) @@ -252,7 +252,7 @@ class WeightsFileHandler(object): model_info.model = trains_in_model # call post model callback functions - for cb in WeightsFileHandler._model_post_callbacks.values(): + for cb in list(WeightsFileHandler._model_post_callbacks.values()): # noinspection PyBroadException try: model_info = cb(WeightsFileHandler.CallbackType.load, model_info) @@ -364,7 +364,7 @@ class WeightsFileHandler(object): # call pre model callback functions model_info.upload_filename = target_filename - for cb in WeightsFileHandler._model_pre_callbacks.values(): + for cb in list(WeightsFileHandler._model_pre_callbacks.values()): # noinspection PyBroadException try: model_info = cb(WeightsFileHandler.CallbackType.save, model_info) @@ -424,7 +424,7 @@ class WeightsFileHandler(object): model_info.model = trains_out_model # call post model callback functions - for cb in WeightsFileHandler._model_post_callbacks.values(): + for cb in list(WeightsFileHandler._model_post_callbacks.values()): # noinspection PyBroadException try: model_info = cb(WeightsFileHandler.CallbackType.save, model_info)