浏览代码

Completely move job status update responsibility to job_dispatcher

jrobinAV 1 年之前
父节点
当前提交
80dd13c0b3
共有 2 个文件被更改,包括 12 次插入14 次删除
  1. 12 2
      taipy/core/_orchestrator/_dispatcher/_job_dispatcher.py
  2. 0 12
      taipy/core/job/job.py

+ 12 - 2
taipy/core/_orchestrator/_dispatcher/_job_dispatcher.py

@@ -11,6 +11,7 @@
 
 import threading
 import time
+import traceback
 from abc import abstractmethod
 from queue import Empty
 from typing import Optional
@@ -147,5 +148,14 @@ class _JobDispatcher(threading.Thread):
 
     @staticmethod
     def _update_job_status(job: Job, exceptions):
-        job.update_status(exceptions)
-        _JobManagerFactory._build_manager()._set(job)
+        """Update the job status based on the success or the failure of its execution."""
+        if exceptions:
+            job.failed()
+            _TaipyLogger._get_logger().error(f" {len(exceptions)} errors occurred during execution of job {job.id}")
+            for e in exceptions:
+                st = "".join(traceback.format_exception(type(e), value=e, tb=e.__traceback__))
+                job._stacktrace.append(st)
+                _TaipyLogger._get_logger().error(st)
+            _JobManagerFactory._build_manager()._set(job)
+        else:
+            job.completed()

+ 0 - 12
taipy/core/job/job.py

@@ -313,18 +313,6 @@ class Job(_Entity, _Labeled):
         if functions:
             self._on_status_change(*functions)
 
-    def update_status(self, exceptions):
-        """Update the job status based on the success or the failure of its execution."""
-        if exceptions:
-            self.failed()
-            self.__logger.error(f" {len(exceptions)} errors occurred during execution of job {self.id}")
-            for e in exceptions:
-                st = "".join(traceback.format_exception(type(e), value=e, tb=e.__traceback__))
-                self._stacktrace.append(st)
-                self.__logger.error(st)
-        else:
-            self.completed()
-
     def __hash__(self):
         return hash(self.id)