[ui] Nodes status monitoring simplification

* store status file last modification time on NodeChunk
* ChunksMonitor: don't stop the underlying thread when changing chunks, only modify the list of monitored files + use a mutex for thread-safety
This commit is contained in:
Yann Lanthony 2019-07-24 17:53:34 +02:00
parent 6b7065dd5d
commit f6a42cb86e
No known key found for this signature in database
GPG key ID: 519FAE6DF7A70642
2 changed files with 35 additions and 51 deletions

View file

@ -144,6 +144,7 @@ class NodeChunk(BaseObject):
self.range = range
self.status = StatusData(node.name, node.nodeType, node.packageName, node.packageVersion)
self.statistics = stats.Statistics()
self.statusFileLastModTime = -1
self._subprocess = None
# notify update in filepaths when node's internal folder changes
self.node.internalFolderChanged.connect(self.nodeFolderChanged)
@ -175,11 +176,13 @@ class NodeChunk(BaseObject):
oldStatus = self.status.status
# No status file => reset status to Status.None
if not os.path.exists(statusFile):
self.statusFileLastModTime = -1
self.status.reset()
else:
with open(statusFile, 'r') as jsonFile:
statusData = json.load(jsonFile)
self.status.fromDict(statusData)
self.statusFileLastModTime = os.path.getmtime(statusFile)
if oldStatus != self.status.status:
self.statusChanged.emit()