eric6/Utilities/BackgroundService.py

changeset 7628
f904d0eef264
parent 7360
9190402e4505
child 7630
4010cc7e9c0b
equal deleted inserted replaced
7626:7f643d41464e 7628:f904d0eef264
148 def __receive(self, lang): 148 def __receive(self, lang):
149 """ 149 """
150 Private method to receive the response from the clients. 150 Private method to receive the response from the clients.
151 151
152 @param lang language of the incomming connection (str) 152 @param lang language of the incomming connection (str)
153 @exception RuntimeError raised if hashes don't match
153 """ 154 """
154 connection = self.connections[lang] 155 connection = self.connections[lang]
155 while connection.bytesAvailable(): 156 while connection.bytesAvailable():
156 if self.__cancelled: 157 if self.__cancelled:
157 connection.readAll() 158 connection.readAll()
165 maxSize = length - len(packedData) 166 maxSize = length - len(packedData)
166 if connection.bytesAvailable() < maxSize: 167 if connection.bytesAvailable() < maxSize:
167 connection.waitForReadyRead(50) 168 connection.waitForReadyRead(50)
168 packedData += connection.read(maxSize) 169 packedData += connection.read(maxSize)
169 170
170 assert adler32(packedData) & 0xffffffff == datahash, \ 171 if adler32(packedData) & 0xffffffff != datahash:
171 'Hashes not equal' 172 raise RuntimeError('Hashes not equal')
172 packedData = packedData.decode('utf-8') 173 packedData = packedData.decode('utf-8')
173 # "check" if is's a tuple of 3 values 174 # "check" if is's a tuple of 3 values
174 fx, fn, data = json.loads(packedData) 175 fx, fn, data = json.loads(packedData)
175 176
176 if fx == 'INIT': 177 if fx == 'INIT':

eric ide

mercurial