Utilities/BackgroundClient.py

changeset 4218
f542ad1f76c5
parent 4021
195a471c327b
child 4221
c9fdc07753a7
diff -r 38e8903f9c2f -r f542ad1f76c5 Utilities/BackgroundClient.py
--- a/Utilities/BackgroundClient.py	Tue Apr 14 19:51:10 2015 +0200
+++ b/Utilities/BackgroundClient.py	Thu Apr 16 19:58:27 2015 +0200
@@ -37,6 +37,7 @@
         @param port port of the background service
         """
         self.services = {}
+        self.batchServices = {}
         
         self.connection = socket.create_connection((host, port))
         ver = b'Python2' if sys.version_info[0] == 2 else b'Python3'
@@ -55,6 +56,11 @@
         try:
             importedModule = __import__(module, globals(), locals(), [], 0)
             self.services[fn] = importedModule.initService()
+            try:
+                self.batchServices["batch_" + fn] = \
+                    importedModule.initBatchService()
+            except AttributeError:
+                pass
             return 'ok'
         except ImportError:
             return 'Import Error'
@@ -112,6 +118,13 @@
                 fx, fn, data = json.loads(packedData)
                 if fx == 'INIT':
                     ret = self.__initClientService(fn, *data)
+                elif fx.startswith("batch_"):
+                    callback = self.batchServices.get(fx)
+                    if callback:
+                        callback(data, self.__send, fx)
+                        ret = "__DONE__"
+                    else:
+                        ret = 'Unknown batch service.'
                 else:
                     callback = self.services.get(fx)
                     if callback:

eric ide

mercurial