martomi / chiadog

A watch dog providing a peace in mind that your Chia farm is running smoothly 24/7.
MIT License
460 stars 123 forks source link

Pytail exception cause thread exit #327

Open Sagittarius opened 2 years ago

Sagittarius commented 2 years ago

https://github.com/martomi/chiadog/blob/99cf0bb73ab3d944105f0c83509c9713b5ba07d4/src/chia_log/log_consumer.py#L75

If there is some non-utf8(like GBK) character, here will throw exception, then make thread exit. I want to make a pr, but I am not good at pyhon, can't fix it. Thx

pieterhelsen commented 2 years ago

Can you paste the stack trace or the name of the exception?

Sagittarius commented 2 years ago

Here is stack trace. Thx man


[2022-01-19 03:59:16] [   ERROR] --- 'utf-8' codec can't decode byte 0xb6 in position 424: invalid start byte (log_consumer.py:79)

Traceback (most recent call last):

File "/chiadog/src/chia_log/log_consumer.py", line 76, in _consume_loop

for log_line in Pygtail(self._expanded_log_path, read_from_end=True, offset_file=self._offset_path):

File "/chiadog/venv/lib/python3.10/site-packages/pygtail/core.py", line 136, in next

return self.next()

File "/chiadog/venv/lib/python3.10/site-packages/pygtail/core.py", line 108, in next

line = self._get_next_line()

File "/chiadog/venv/lib/python3.10/site-packages/pygtail/core.py", line 280, in _get_next_line

line = self._filehandle().readline()

File "/usr/local/lib/python3.10/codecs.py", line 322, in decode

(result, consumed) = self._buffer_decode(data, self.errors, final)

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 424: invalid start byte