Fix subprocess current_task return should return class instance

This commit is contained in:
allegroai 2021-10-24 17:33:49 +03:00
parent 1795344ec3
commit ef6b381710

View File

@ -187,7 +187,7 @@ class Task(_Task):
# check if we have no main Task, but the main process created one. # check if we have no main Task, but the main process created one.
if not cls.__main_task and cls.__get_master_id_task_id(): if not cls.__main_task and cls.__get_master_id_task_id():
# initialize the Task, connect to stdout # initialize the Task, connect to stdout
Task.init() cls.init()
# return main Task # return main Task
return cls.__main_task return cls.__main_task
@ -519,7 +519,7 @@ class Task(_Task):
cls.__update_master_pid_task(task=task) cls.__update_master_pid_task(task=task)
else: else:
# subprocess should get back the task info # subprocess should get back the task info
task = Task.get_task(task_id=is_sub_process_task_id) task = cls.get_task(task_id=is_sub_process_task_id)
else: else:
# if this is the main process, create the task # if this is the main process, create the task
if not is_sub_process_task_id: if not is_sub_process_task_id:
@ -539,7 +539,7 @@ class Task(_Task):
task.set_initial_iteration(int(task.data.last_iteration) + 1) task.set_initial_iteration(int(task.data.last_iteration) + 1)
else: else:
# subprocess should get back the task info # subprocess should get back the task info
task = Task.get_task(task_id=is_sub_process_task_id) task = cls.get_task(task_id=is_sub_process_task_id)
except Exception: except Exception:
raise raise
else: else: