eric6/Utilities/BackgroundClient.py

branch
multi_processing
changeset 7646
39e3db2b4936
parent 7564
787684e6f2f3
parent 7639
422fd05e9c91
child 7802
eefe954f01e8
--- a/eric6/Utilities/BackgroundClient.py	Wed Jun 17 17:14:12 2020 +0200
+++ b/eric6/Utilities/BackgroundClient.py	Sun Jul 05 11:11:24 2020 +0200
@@ -9,13 +9,7 @@
 checkers and other python interpreter dependent functions.
 """
 
-from __future__ import unicode_literals
-try:
-    bytes = unicode         # __IGNORE_EXCEPTION__
-    import StringIO as io   # __IGNORE_EXCEPTION__
-except NameError:
-    import io       # __IGNORE_WARNING__
-
+import io
 import json
 import socket
 import struct
@@ -45,7 +39,7 @@
         self.batchServices = {}
         
         self.connection = socket.create_connection((host, port))
-        ver = b'Python2' if sys.version_info[0] == 2 else b'Python3'
+        ver = b'Python3'
         self.connection.sendall(ver)
         self.__maxProcs = maxProcs
 
@@ -87,8 +81,7 @@
             data = str(data)
         
         packedData = json.dumps([fx, fn, data])
-        if sys.version_info[0] >= 3:
-            packedData = bytes(packedData, 'utf-8')
+        packedData = bytes(packedData, 'utf-8')
         header = struct.pack(
             b'!II', len(packedData), adler32(packedData) & 0xffffffff)
         self.connection.sendall(header)
@@ -144,6 +137,8 @@
     def run(self):
         """
         Public method implementing the main loop of the client.
+        
+        @exception RuntimeError raised if hashes don't match
         """
         try:
             while True:
@@ -159,10 +154,10 @@
                 if messageType != b"JOB   ":
                     continue
                 
-                assert adler32(packedData) & 0xffffffff == datahash, \
-                    'Hashes not equal'
-                if sys.version_info[0] >= 3:
-                    packedData = packedData.decode('utf-8')
+                if adler32(packedData) & 0xffffffff != datahash:
+                    raise RuntimeError('Hashes not equal')
+                
+                packedData = packedData.decode('utf-8')
                 
                 fx, fn, data = json.loads(packedData)
                 if fx == 'INIT':

eric ide

mercurial