@@ -44,6 +44,7 @@ def __init__(self, parent=None):
44
44
self ._stopFlag = Event ()
45
45
self ._refreshInterval = 5 # refresh interval in seconds
46
46
self ._files = []
47
+ self ._nodes = []
47
48
if submitters :
48
49
self ._filePollerRefresh = PollerRefreshStatus .MINIMAL_ENABLED
49
50
else :
@@ -53,7 +54,7 @@ def __del__(self):
53
54
self ._threadPool .terminate ()
54
55
self ._threadPool .join ()
55
56
56
- def start (self , files = None ):
57
+ def start (self , files = None , nodes = None ):
57
58
""" Start polling thread.
58
59
59
60
Args:
@@ -66,6 +67,7 @@ def start(self, files=None):
66
67
return
67
68
self ._stopFlag .clear ()
68
69
self ._files = files or []
70
+ self ._nodes = nodes or []
69
71
self ._thread = Thread (target = self .run )
70
72
self ._thread .start ()
71
73
@@ -78,6 +80,15 @@ def setFiles(self, files):
78
80
with self ._mutex :
79
81
self ._files = files
80
82
83
+ def setNodes (self , nodes ):
84
+ """ Set the list of nodes to monitor
85
+
86
+ Args:
87
+ nodes: the list of nodes to monitor
88
+ """
89
+ with self ._mutex :
90
+ self ._nodes = nodes
91
+
81
92
def stop (self ):
82
93
""" Request polling thread to stop. """
83
94
if not self ._thread :
@@ -94,6 +105,13 @@ def getFileLastModTime(f):
94
105
except OSError :
95
106
return - 1
96
107
108
+ @staticmethod
109
+ def updatePluginEnvStatus (n ):
110
+ """ Will update the status of the plugin env """
111
+ print ("Refreshing " + str (n ))
112
+ n .isEnvBuild = n .nodeDesc .isBuilt
113
+ n .buildStatusChanged .emit ()
114
+
97
115
def run (self ):
98
116
""" Poll watched files for last modification time. """
99
117
while not self ._stopFlag .wait (self ._refreshInterval ):
@@ -103,6 +121,8 @@ def run(self):
103
121
with self ._mutex :
104
122
if files == self ._files :
105
123
self .timesAvailable .emit (times )
124
+ #update plugin nodes
125
+ _ = self ._threadPool .map (self .updatePluginEnvStatus , self ._nodes )
106
126
107
127
def onFilePollerRefreshChanged (self , value ):
108
128
""" Stop or start the file poller depending on the new refresh status. """
@@ -116,7 +136,6 @@ def onFilePollerRefreshChanged(self, value):
116
136
filePollerRefresh = Property (int , lambda self : self ._filePollerRefresh .value , constant = True )
117
137
filePollerRefreshReady = Signal () # The refresh status has been updated and is ready to be used
118
138
119
-
120
139
class ChunksMonitor (QObject ):
121
140
"""
122
141
ChunksMonitor regularly check NodeChunks' status files for modification and trigger their update on change.
@@ -147,6 +166,8 @@ def setChunks(self, chunks):
147
166
self .monitorableChunks = chunks
148
167
files , monitoredChunks = self .watchedStatusFiles
149
168
self ._filesTimePoller .setFiles (files )
169
+ pluginNodes = [c .node for c in chunks if c .node .isPlugin ]
170
+ self ._filesTimePoller .setNodes (pluginNodes )
150
171
self .monitoredChunks = monitoredChunks
151
172
152
173
def stop (self ):
@@ -172,7 +193,8 @@ def watchedStatusFiles(self):
172
193
elif self .filePollerRefresh is PollerRefreshStatus .MINIMAL_ENABLED .value :
173
194
for c in self .monitorableChunks :
174
195
# When a chunk's status is ERROR, it may be externally re-submitted and it should thus still be monitored
175
- if c ._status .status is Status .SUBMITTED or c ._status .status is Status .RUNNING or c ._status .status is Status .ERROR :
196
+ #Plugin nodes are always moniotored
197
+ if c .node .isPlugin or c ._status .status is Status .SUBMITTED or c ._status .status is Status .RUNNING or c ._status .status is Status .ERROR :
176
198
files .append (c .statusFile )
177
199
chunks .append (c )
178
200
return files , chunks
0 commit comments