130 if sys.version_info[0] == 3: |
130 if sys.version_info[0] == 3: |
131 packedData = bytes(packedData, 'utf-8') |
131 packedData = bytes(packedData, 'utf-8') |
132 header = struct.pack( |
132 header = struct.pack( |
133 b'!II', len(packedData), adler32(packedData) & 0xffffffff) |
133 b'!II', len(packedData), adler32(packedData) & 0xffffffff) |
134 connection.write(header) |
134 connection.write(header) |
|
135 connection.write(b'JOB ') # 6 character message type |
135 connection.write(packedData) |
136 connection.write(packedData) |
136 |
137 |
137 def __receive(self, lang): |
138 def __receive(self, lang): |
138 """ |
139 """ |
139 Private method to receive the response from the clients. |
140 Private method to receive the response from the clients. |
140 |
141 |
141 @param lang language of the incomming connection (str) |
142 @param lang language of the incomming connection (str) |
142 """ |
143 """ |
143 connection = self.connections[lang] |
144 connection = self.connections[lang] |
144 while connection.bytesAvailable(): |
145 while connection.bytesAvailable(): |
145 header = connection.read(8) |
146 header = connection.read(struct.calcsize(b'!II')) |
146 length, datahash = struct.unpack(b'!II', header) |
147 length, datahash = struct.unpack(b'!II', header) |
147 |
148 |
148 packedData = b'' |
149 packedData = b'' |
149 while len(packedData) < length: |
150 while len(packedData) < length: |
150 connection.waitForReadyRead(50) |
151 connection.waitForReadyRead(50) |
288 break |
289 break |
289 else: |
290 else: |
290 self.__queue.append(args) |
291 self.__queue.append(args) |
291 self.__processQueue() |
292 self.__processQueue() |
292 |
293 |
|
294 def requestCancel(self, lang): |
|
295 """ |
|
296 Public method to ask a batch job to terminate. |
|
297 |
|
298 @param lang language to connect to (str) |
|
299 """ |
|
300 connection = self.connections.get(lang) |
|
301 if connection is None: |
|
302 return |
|
303 else: |
|
304 header = struct.pack(b'!II', 0, 0) |
|
305 connection.write(header) |
|
306 connection.write(b'CANCEL') # 6 character message type |
|
307 |
293 def serviceConnect( |
308 def serviceConnect( |
294 self, fx, lang, modulepath, module, callback, |
309 self, fx, lang, modulepath, module, callback, |
295 onErrorCallback=None, onBatchDone=None): |
310 onErrorCallback=None, onBatchDone=None): |
296 """ |
311 """ |
297 Public method to announce a new service to the background |
312 Public method to announce a new service to the background |