From bc94a555253b82ff7ad6e996947a36b98282661d Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Thu, 22 Dec 2022 22:05:14 +0200 Subject: [PATCH] Fix crash when calling `task.flush(wait_for_uploads=True)` while executing remotely --- clearml/backend_interface/metrics/reporter.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/clearml/backend_interface/metrics/reporter.py b/clearml/backend_interface/metrics/reporter.py index 36eacb98..239863b2 100644 --- a/clearml/backend_interface/metrics/reporter.py +++ b/clearml/backend_interface/metrics/reporter.py @@ -108,14 +108,19 @@ class BackgroundReportService(BackgroundMonitor, AsyncManagerMixin): if isinstance(self._empty_state_event, ForkEvent): self._flush_event.set() tic = time() - while self._thread and self._thread.is_alive() and (not timeout or time()-tic < timeout): + + while ( + self._thread + and (self._thread is True or self._thread.is_alive()) + and (not timeout or time() - tic < timeout) + ): if self._empty_state_event.wait(timeout=1.0): break if self._event.wait(0) or self._done_ev.wait(0): break # if enough time passed and the flush event was not cleared, # there is no daemon thread running, we should leave - if time()-tic > self.__daemon_live_check_timeout and self._flush_event.wait(0): + if time() - tic > self.__daemon_live_check_timeout and self._flush_event.wait(0): self._write() break elif isinstance(self._empty_state_event, SafeEvent):