Core: patch stream_input to ignore non-parsable input (such as EOF encoded as 0xff) (#854)

This commit is contained in:
Fabian Dill
2022-08-03 14:53:14 +02:00
committed by GitHub
parent b47cca4515
commit 59918b9dbc

View File

@@ -479,9 +479,13 @@ def init_logging(name: str, loglevel: typing.Union[str, int] = logging.INFO, wri
def stream_input(stream, queue):
def queuer():
while 1:
text = stream.readline().strip()
if text:
queue.put_nowait(text)
try:
text = stream.readline().strip()
except UnicodeDecodeError as e:
logging.exception(e)
else:
if text:
queue.put_nowait(text)
from threading import Thread
thread = Thread(target=queuer, name=f"Stream handler for {stream.name}", daemon=True)