eric6/Utilities/BackgroundService.py

branch
maintenance
changeset 8273
698ae46f40a4
parent 8176
31965986ecd1
parent 8264
f95dde35d0ab
child 8400
b3eefd7e58d1
--- a/eric6/Utilities/BackgroundService.py	Fri Apr 02 11:59:41 2021 +0200
+++ b/eric6/Utilities/BackgroundService.py	Sat May 01 14:27:20 2021 +0200
@@ -13,6 +13,7 @@
 import struct
 import sys
 from zlib import adler32
+import contextlib
 
 from PyQt5.QtCore import QProcess, pyqtSignal, QTimer
 from PyQt5.QtWidgets import QApplication
@@ -53,7 +54,7 @@
         self.__queue = []
         self.services = {}
 
-        super(BackgroundService, self).__init__(parent)
+        super().__init__(parent)
 
         networkInterface = Preferences.getDebugger("NetworkInterface")
         if networkInterface == "all" or '.' in networkInterface:
@@ -183,7 +184,15 @@
             fx, fn, data = json.loads(packedData)
             
             if fx == 'INIT':
-                pass
+                if data != "ok":
+                    E5MessageBox.critical(
+                        None,
+                        self.tr("Initialization of Background Service"),
+                        self.tr(
+                            "<p>Initialization of Background Service"
+                            " <b>{0}</b> failed.</p><p>Reason: {1}</p>")
+                        .format(fn, data)
+                    )
             elif fx == 'EXCEPTION':
                 # Remove connection because it'll close anyway
                 self.connections.pop(lang, None)
@@ -215,14 +224,11 @@
                     self.enqueueRequest(*self.runningJob)
                 else:
                     fx, lng, fn, data = self.runningJob
-                    try:
+                    with contextlib.suppress(KeyError, TypeError):
                         self.services[(fx, lng)][3](fx, lng, fn, self.tr(
                             "An error in Eric's background client stopped the"
                             " service.")
                         )
-                    except (KeyError, TypeError):
-                        # ignore silently
-                        pass
                 if res != E5MessageBox.No:
                     self.isWorking = None
                     self.restartService(lang, True)
@@ -240,7 +246,9 @@
                             callback[2](fn, *data)
                         elif isinstance(data, str):
                             callback[3](fx, lang, fn, data)
-                    continue
+                    if data == 'Unknown batch service.':
+                        self.batchJobDone.emit(fx, lang)
+                        self.__cancelled = True
                 else:
                     self.batchJobDone.emit(fx, lang)
             else:

eric ide

mercurial