Small optimization to FrontendCommunicationsHandler.py

This commit is contained in:
AccentuSoft
2022-01-24 08:49:37 +02:00
parent ecca48102e
commit e3bb2eee0c

View File

@@ -161,8 +161,10 @@ class CommunicationsHandler(QtCore.QObject):
except OSError: except OSError:
# This would typically occur if the socket is already shut down. # This would typically occur if the socket is already shut down.
self.mainWindow.MESSAGEHANDLER.debug('Tried to shutdown socket that was already shut down.') self.mainWindow.MESSAGEHANDLER.debug('Tried to shutdown socket that was already shut down.')
self.sock.close() try:
self.sock = None self.sock.close()
finally:
self.sock = None
return False return False
@@ -265,9 +267,10 @@ class CommunicationsHandler(QtCore.QObject):
messages = receivedInfo.split(b'\x00\x00\x00') messages = receivedInfo.split(b'\x00\x00\x00')
if not receivedInfo.endswith(b'\x00\x00\x00'): if not receivedInfo.endswith(b'\x00\x00\x00'):
oldData = messages[-1] oldData = messages[-1]
messages = messages[:-1]
else: else:
oldData = b'' oldData = b''
# Last message is either blank (i.e. '') or incomplete data, so we ignore it.
messages = messages[:-1]
for message in messages: for message in messages:
message = b64decode(message) message = b64decode(message)
decryptedInfo = self.decryptTransmission(message) decryptedInfo = self.decryptTransmission(message)