diff -r 4df8f9fc7ea9 -r c9fdc07753a7 Utilities/BackgroundService.py --- a/Utilities/BackgroundService.py Fri Apr 17 18:57:38 2015 +0200 +++ b/Utilities/BackgroundService.py Sat Apr 18 19:14:15 2015 +0200 @@ -132,6 +132,7 @@ header = struct.pack( b'!II', len(packedData), adler32(packedData) & 0xffffffff) connection.write(header) + connection.write(b'JOB ') # 6 character message type connection.write(packedData) def __receive(self, lang): @@ -142,7 +143,7 @@ """ connection = self.connections[lang] while connection.bytesAvailable(): - header = connection.read(8) + header = connection.read(struct.calcsize(b'!II')) length, datahash = struct.unpack(b'!II', header) packedData = b'' @@ -290,6 +291,20 @@ self.__queue.append(args) self.__processQueue() + def requestCancel(self, lang): + """ + Public method to ask a batch job to terminate. + + @param lang language to connect to (str) + """ + connection = self.connections.get(lang) + if connection is None: + return + else: + header = struct.pack(b'!II', 0, 0) + connection.write(header) + connection.write(b'CANCEL') # 6 character message type + def serviceConnect( self, fx, lang, modulepath, module, callback, onErrorCallback=None, onBatchDone=None):