Cezary Wagner <cezary.wag...@gmail.com> added the comment:
Another code try - this time I am using task: import asyncio import sys async def process_line_reader(process, on_line=None, on_eof=None): while not process.stdout.at_eof(): # BUG? after first line it becomes dead line = await process.stdout.readline() if on_line is not None: on_line(line.decode()) if on_eof is not None: on_eof() print('eof') async def run_stockfish(): STOCKFISH_PATH = r'C:\root\chess\stockfish\stockfish 10\stockfish_10_x64_bmi2.exe' stockfish = await asyncio.subprocess.create_subprocess_exec( STOCKFISH_PATH, stdin=asyncio.subprocess.PIPE, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE) stockfish.stdin.write('uci'.encode()) task = asyncio.create_task(process_line_reader( process=stockfish, on_line=lambda line: print(f'{line}') )) # await task await stockfish.wait() if sys.platform == "win32": asyncio.set_event_loop_policy( asyncio.WindowsProactorEventLoopPolicy()) asyncio.run(run_stockfish(), debug=True) print('done') All is blocked after first line (no print of eof or done): C:\root\Python37-64\python.exe "C:/Users/Cezary Wagner/PycharmProjects/cw_chess_uci/sandbox/async_proxy/s02_async_stockfish.py" Stockfish 10 64 BMI2 by T. Romstad, M. Costalba, J. Kiiski, G. Linscott ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue35268> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com