From f3626a83c87ba5dce243488f50a80498f43fbbdd Mon Sep 17 00:00:00 2001 From: Aurore LAFAURIE Date: Tue, 11 Jun 2024 12:11:12 +0200 Subject: [PATCH] [core] elapsedTime set only once at the end of the process to avoid repetition of code --- meshroom/core/node.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/meshroom/core/node.py b/meshroom/core/node.py index 07239617..aceee3f7 100644 --- a/meshroom/core/node.py +++ b/meshroom/core/node.py @@ -404,6 +404,7 @@ class NodeChunk(BaseObject): global runningProcesses runningProcesses[self.name] = self self._status.initStartCompute() + exceptionStatus = None startTime = time.time() self.upgradeStatusTo(Status.RUNNING) self.statThread = stats.StatisticsThread(self) @@ -411,17 +412,17 @@ class NodeChunk(BaseObject): try: self.node.nodeDesc.processChunk(self) except Exception as e: - self._status.elapsedTime = time.time() - startTime if self._status.status != Status.STOPPED: - self.upgradeStatusTo(Status.ERROR) + exceptionStatus = Status.ERROR raise except (KeyboardInterrupt, SystemError, GeneratorExit) as e: - self._status.elapsedTime = time.time() - startTime - self.upgradeStatusTo(Status.STOPPED) + exceptionStatus = Status.STOPPED raise finally: self._status.initEndCompute() self._status.elapsedTime = time.time() - startTime + if exceptionStatus is not None: + self.upgradeStatusTo(exceptionStatus) logging.info(' - elapsed time: {}'.format(self._status.elapsedTimeStr)) # ask and wait for the stats thread to stop self.statThread.stopRequest()