From 787079669faed15434768236a8e2285c734f3343 Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Thu, 11 Feb 2021 14:28:05 +0200 Subject: [PATCH] Fix exception at exit in python 3.8+ on macOS/Windows --- clearml/utilities/process/mp.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/clearml/utilities/process/mp.py b/clearml/utilities/process/mp.py index b810a414..225c7480 100644 --- a/clearml/utilities/process/mp.py +++ b/clearml/utilities/process/mp.py @@ -216,7 +216,16 @@ class BackgroundMonitor(object): current_process()._config['daemon'] = False # noqa except BaseException: pass - BackgroundMonitor._main_process.start() + # try to start the background process, if we fail retry again, or crash + for i in range(4): + try: + BackgroundMonitor._main_process.start() + break + except BaseException: + if i < 3: + sleep(1) + continue + raise if un_daemonize: # noinspection PyBroadException try: