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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

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 stream_input(stream, queue):
def queuer(): def queuer():
while 1: while 1:
text = stream.readline().strip() try:
if text: text = stream.readline().strip()
queue.put_nowait(text) except UnicodeDecodeError as e:
logging.exception(e)
else:
if text:
queue.put_nowait(text)
from threading import Thread from threading import Thread
thread = Thread(target=queuer, name=f"Stream handler for {stream.name}", daemon=True) thread = Thread(target=queuer, name=f"Stream handler for {stream.name}", daemon=True)