busimus / cutelog

GUI for logging
MIT License
479 stars 45 forks source link

Error when deserializing received data #6

Closed dimapu closed 6 years ago

dimapu commented 6 years ago

Hi, thanks for this nice software.

Sometimes I get an error

Traceback (most recent call last):
  File "d:\pf\ana3\lib\site-packages\cutelog\listener.py", line 149, in run
    data = self.deserialize(data)
_pickle.UnpicklingError: pickle data was truncated

It leads to the crash of the program. I am not sure why it happens, but wrapping whose lines in LogConnection.run() in listener.py with try... except... seems to help (probably as a workaround until more stable data reading can be done):

            if not data:
                continue

            try:
                data = self.deserialize(data)
            except Exception as e:
                self.log.warning('Error deserializing data (len={}). ' 
                                 'The following exception was raised: {}'
                                 .format(len(data), e))
                continue
            record = logging.makeLogRecord(data)
            self.new_record.emit(record)

Best regards, Dima.

busimus commented 6 years ago

Thanks for reporting the issue. I did my best to make the listener more robust, so it should now hopefully have no problem with slow connections, large records, or malformed payloads (although right now it only complains to console when it fails to deserialize a fully read record, I'll think about how to improve that in the future). Please update to version 1.1.9.