251 if process: |
251 if process: |
252 self.processes[language] = process, interpreter |
252 self.processes[language] = process, interpreter |
253 |
253 |
254 def enqueueRequest(self, fx, lang, fn, data): |
254 def enqueueRequest(self, fx, lang, fn, data): |
255 """ |
255 """ |
256 Implement a queued processing of incomming events. |
256 Public method implementing a queued processing of incomming events. |
257 |
257 |
258 Dublicate service requests updates an older request to avoid overrun or |
258 Dublicate service requests updates an older request to avoid overrun or |
259 starving of the services. |
259 starving of the services. |
260 @param fx function name of the service (str) |
260 @param fx function name of the service (str) |
261 @param lang language to connect to (str) |
261 @param lang language to connect to (str) |
278 |
278 |
279 def serviceConnect( |
279 def serviceConnect( |
280 self, fx, lang, modulepath, module, callback, |
280 self, fx, lang, modulepath, module, callback, |
281 onErrorCallback=None): |
281 onErrorCallback=None): |
282 """ |
282 """ |
283 Announce a new service to the background service/ client. |
283 Public method to announce a new service to the background |
|
284 service/client. |
284 |
285 |
285 @param fx function name of the service (str) |
286 @param fx function name of the service (str) |
286 @param lang language of the new service (str) |
287 @param lang language of the new service (str) |
287 @param modulepath full path to the module (str) |
288 @param modulepath full path to the module (str) |
288 @param module name to import (str) |
289 @param module name to import (str) |
295 if onErrorCallback: |
296 if onErrorCallback: |
296 self.serviceNotAvailable.connect(onErrorCallback) |
297 self.serviceNotAvailable.connect(onErrorCallback) |
297 |
298 |
298 def serviceDisconnect(self, fx, lang): |
299 def serviceDisconnect(self, fx, lang): |
299 """ |
300 """ |
300 Remove the service from the service list. |
301 Public method to remove the service from the service list. |
301 |
302 |
302 @param fx function name of the service (function) |
303 @param fx function name of the service (function) |
303 @param lang language of the service (str) |
304 @param lang language of the service (str) |
304 """ |
305 """ |
305 serviceArgs = self.services.pop((fx, lang), None) |
306 serviceArgs = self.services.pop((fx, lang), None) |
306 if serviceArgs and serviceArgs[3]: |
307 if serviceArgs and serviceArgs[3]: |
307 self.serviceNotAvailable.disconnect(serviceArgs[3]) |
308 self.serviceNotAvailable.disconnect(serviceArgs[3]) |
308 |
309 |
309 def on_newConnection(self): |
310 def on_newConnection(self): |
310 """ |
311 """ |
311 Slot for new incomming connections from the clients. |
312 Private slot for new incomming connections from the clients. |
312 """ |
313 """ |
313 connection = self.nextPendingConnection() |
314 connection = self.nextPendingConnection() |
314 if not connection.waitForReadyRead(1000): |
315 if not connection.waitForReadyRead(1000): |
315 return |
316 return |
316 lang = connection.read(64) |
317 lang = connection.read(64) |
341 if editor.getLanguage() == lang: |
342 if editor.getLanguage() == lang: |
342 QTimer.singleShot(0, editor.checkSyntax) |
343 QTimer.singleShot(0, editor.checkSyntax) |
343 |
344 |
344 def on_disconnectSocket(self, lang): |
345 def on_disconnectSocket(self, lang): |
345 """ |
346 """ |
346 Slot is called when connection to a client is lost. |
347 Private slot called when connection to a client is lost. |
347 |
348 |
348 @param lang client language which connection is lost (str) |
349 @param lang client language which connection is lost (str) |
349 """ |
350 """ |
350 conn = self.connections.pop(lang, None) |
351 conn = self.connections.pop(lang, None) |
351 if conn: |
352 if conn: |
369 if res: |
370 if res: |
370 self.restartService(lang) |
371 self.restartService(lang) |
371 |
372 |
372 def shutdown(self): |
373 def shutdown(self): |
373 """ |
374 """ |
374 Cleanup the connections and processes when eric is shuting down. |
375 Public method to cleanup the connections and processes when eric is |
|
376 shuting down. |
375 """ |
377 """ |
376 for connection in self.connections.values(): |
378 for connection in self.connections.values(): |
377 # Prevent calling of on_disconnectSocket |
379 # Prevent calling of on_disconnectSocket |
378 connection.blockSignals(True) |
380 connection.blockSignals(True) |
379 connection.close() |
381 connection.close() |