[core] NodeChunk: Do not raise an error when we stop a chunk that is not running

When we stop the process of a node with multiple chunks, the Node
function will call the stop function of each chunk.
So, the chunck status could be SUBMITTED, RUNNING or ERROR.
This commit is contained in:
Fabien Castan 2025-04-13 10:08:28 +02:00
parent 008d6c75ee
commit 44ec6f0be7

View file

@ -535,8 +535,22 @@ class NodeChunk(BaseObject):
def stopProcess(self): def stopProcess(self):
if self.isExtern(): if self.isExtern():
raise ValueError("Cannot stop process: node is computed externally (another instance of Meshroom)") raise ValueError("Cannot stop process: node is computed externally (another instance of Meshroom)")
# Ensure that we are up-to-date
self.updateStatusFromCache()
if self._status.status != Status.RUNNING: if self._status.status != Status.RUNNING:
raise ValueError(f"Cannot stop process: node is not running (status is: {self._status.status}).") # When we stop the process of a node with multiple chunks, the Node function will call the stop function of each chunk.
# So, the chunck status could be SUBMITTED, RUNNING or ERROR.
if self._status.status is Status.SUBMITTED:
self.upgradeStatusTo(Status.NONE)
elif self._status.status in (Status.ERROR, Status.STOPPED, Status.KILLED, Status.SUCCESS, Status.NONE):
# Nothing to do, the computation is already stopped.
pass
else:
logging.debug(f"Cannot stop process: node is not running (status is: {self._status.status}).")
return
self.node.nodeDesc.stopProcess(self) self.node.nodeDesc.stopProcess(self)