110 @param fx remote function name to execute (str) |
110 @param fx remote function name to execute (str) |
111 @param lang language to connect to (str) |
111 @param lang language to connect to (str) |
112 @param fn filename for identification (str) |
112 @param fn filename for identification (str) |
113 @param data function argument(s) (any basic datatype) |
113 @param data function argument(s) (any basic datatype) |
114 """ |
114 """ |
|
115 self.__cancelled = False |
115 connection = self.connections.get(lang) |
116 connection = self.connections.get(lang) |
116 if connection is None: |
117 if connection is None: |
117 if fx != 'INIT': |
118 if fx != 'INIT': |
118 # Avoid growing recursion deep which could itself result in an |
119 # Avoid growing recursion deep which could itself result in an |
119 # exception |
120 # exception |
141 |
142 |
142 @param lang language of the incomming connection (str) |
143 @param lang language of the incomming connection (str) |
143 """ |
144 """ |
144 connection = self.connections[lang] |
145 connection = self.connections[lang] |
145 while connection.bytesAvailable(): |
146 while connection.bytesAvailable(): |
|
147 if self.__cancelled: |
|
148 connection.readAll() |
|
149 continue |
|
150 |
146 header = connection.read(struct.calcsize(b'!II')) |
151 header = connection.read(struct.calcsize(b'!II')) |
147 length, datahash = struct.unpack(b'!II', header) |
152 length, datahash = struct.unpack(b'!II', header) |
148 |
153 |
149 packedData = b'' |
154 packedData = b'' |
150 while len(packedData) < length: |
155 while len(packedData) < length: |
289 break |
294 break |
290 else: |
295 else: |
291 self.__queue.append(args) |
296 self.__queue.append(args) |
292 self.__processQueue() |
297 self.__processQueue() |
293 |
298 |
294 def requestCancel(self, lang): |
299 def requestCancel(self, fx, lang): |
295 """ |
300 """ |
296 Public method to ask a batch job to terminate. |
301 Public method to ask a batch job to terminate. |
297 |
302 |
298 @param lang language to connect to (str) |
303 @param lang language to connect to (str) |
299 """ |
304 """ |
|
305 self.__cancelled = True |
|
306 |
|
307 entriesToRemove = [] |
|
308 for pendingArg in self.__queue: |
|
309 if pendingArg[:2] == [fx, lang]: |
|
310 entriesToRemove.append(pendingArg) |
|
311 for entryToRemove in entriesToRemove: |
|
312 self.__queue.remove(entryToRemove) |
|
313 |
300 connection = self.connections.get(lang) |
314 connection = self.connections.get(lang) |
301 if connection is None: |
315 if connection is None: |
302 return |
316 return |
303 else: |
317 else: |
304 header = struct.pack(b'!II', 0, 0) |
318 header = struct.pack(b'!II', 0, 0) |