mirror of
https://github.com/clearml/clearml
synced 2025-02-07 13:23:40 +00:00
Fix Task.close() should remove current_task() reference
This commit is contained in:
parent
3c66c42157
commit
9a2d091849
@ -1364,6 +1364,7 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
|
||||
def set_system_tags(self, tags):
|
||||
# type: (Sequence[str]) -> ()
|
||||
assert isinstance(tags, (list, tuple))
|
||||
tags = list(set(tags))
|
||||
if Session.check_min_api_version('2.3'):
|
||||
self._set_task_property("system_tags", tags)
|
||||
self._edit(system_tags=self.data.system_tags)
|
||||
@ -2208,7 +2209,7 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
|
||||
|
||||
@classmethod
|
||||
def __update_master_pid_task(cls, pid=None, task=None):
|
||||
# type: (Optional[int], Union[str, Task]) -> None
|
||||
# type: (Optional[int], Optional[Union[str, Task]]) -> None
|
||||
pid = pid or os.getpid()
|
||||
if not task:
|
||||
PROC_MASTER_ID_ENV_VAR.set(str(pid) + ':')
|
||||
@ -2223,11 +2224,11 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
|
||||
@classmethod
|
||||
def __get_master_id_task_id(cls):
|
||||
# type: () -> Optional[str]
|
||||
master_task_id = PROC_MASTER_ID_ENV_VAR.get().split(':')
|
||||
master_pid, _, master_task_id = PROC_MASTER_ID_ENV_VAR.get('').partition(':')
|
||||
# we could not find a task ID, revert to old stub behaviour
|
||||
if len(master_task_id) < 2 or not master_task_id[1]:
|
||||
if not master_task_id:
|
||||
return None
|
||||
return master_task_id[1]
|
||||
return master_task_id
|
||||
|
||||
@classmethod
|
||||
def __get_master_process_id(cls):
|
||||
|
@ -184,7 +184,7 @@ class Task(_Task):
|
||||
:return: The current running Task (experiment).
|
||||
"""
|
||||
# check if we have no main Task, but the main process created one.
|
||||
if not cls.__main_task and PROC_MASTER_ID_ENV_VAR.get():
|
||||
if not cls.__main_task and cls.__get_master_id_task_id():
|
||||
# initialize the Task, connect to stdout
|
||||
Task.init()
|
||||
# return main Task
|
||||
@ -3061,6 +3061,7 @@ class Task(_Task):
|
||||
# this is so in theory we can close a main task and start a new one
|
||||
if self.is_main_task():
|
||||
Task.__main_task = None
|
||||
Task.__update_master_pid_task(task=None)
|
||||
except Exception:
|
||||
# make sure we do not interrupt the exit process
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user