diff --git a/CommonClient.py b/CommonClient.py index 682f55ba4d3e..53f7d67544ae 100644 --- a/CommonClient.py +++ b/CommonClient.py @@ -540,14 +540,26 @@ async def process_server_cmd(ctx: CommonContext, args: dict): ctx.on_package(cmd, args) +def stream_input(stream, queue): + def queuer(): + text = stream.readline().strip() + if text: + queue.put_nowait(text) + + from threading import Thread + thread = Thread(target=queuer, name=f"Stream handler for {stream.name}", daemon=True) + thread.start() + return thread + + async def console_loop(ctx: CommonContext): import sys commandprocessor = ctx.command_processor(ctx) + queue = asyncio.Queue() + stream_input(sys.stdin, queue) while not ctx.exit_event.is_set(): try: - input_text = await asyncio.get_event_loop().run_in_executor( - None, sys.stdin.readline - ) + input_text = await queue.get() input_text = input_text.strip() if ctx.input_requests > 0: diff --git a/requirements.txt b/requirements.txt index bf31f568f84f..c32a51858418 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,8 @@ colorama>=0.4.4 -websockets>=10.0 +websockets>=10.1 PyYAML>=6.0 fuzzywuzzy>=0.18.0 -prompt_toolkit>=3.0.22 +prompt_toolkit>=3.0.23 appdirs>=1.4.4 jinja2>=3.0.3 schema>=0.7.4