From 03bf764dc749c5718ca31e5cafea6d5df66ef132 Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Fri, 22 May 2020 11:04:12 +0300 Subject: [PATCH] Make sure Task.close() will wait for repository package analysis (timeout 5 minutes) --- trains/task.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/trains/task.py b/trains/task.py index 1a0f6294..2ff0099a 100644 --- a/trains/task.py +++ b/trains/task.py @@ -1034,8 +1034,16 @@ class Task(_Task): .. warning:: Only call :meth:`Task.close` if you are certain the Task is not needed. """ + if self._at_exit_called: + return + # store is main before we call at_exit, because will will Null it is_main = self.is_main_task() + + # wait for repository detection (5 minutes should be reasonable time to detect all packages) + if self._logger and not self.__is_subprocess(): + self._wait_for_repo_detection(timeout=300.) + self.__shutdown() # unregister atexit callbacks and signal hooks, if we are the main task if is_main: