From 9307a932adfa5799fa3e29f40ef123c2377fd898 Mon Sep 17 00:00:00 2001 From: Roland Dobai Date: Wed, 31 Aug 2022 16:03:57 +0200 Subject: [PATCH] Tools: Handle IO error in idf.py output capturing Closes https://github.com/espressif/esp-idf/issues/9649 --- tools/idf_py_actions/tools.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/idf_py_actions/tools.py b/tools/idf_py_actions/tools.py index 9a24ff4d9e3..9a3713ad4b9 100644 --- a/tools/idf_py_actions/tools.py +++ b/tools/idf_py_actions/tools.py @@ -240,10 +240,14 @@ def print_progression(output: str) -> None: print(fit_text_in_terminal(output.strip('\n\r')), end='', file=output_stream) async def read_stream() -> Optional[str]: - output_b = await input_stream.readline() - if not output_b: + try: + output_b = await input_stream.readline() + return output_b.decode(errors='ignore') + except (asyncio.LimitOverrunError, asyncio.IncompleteReadError) as e: + print(e, file=sys.stderr) + return None + except AttributeError: return None - return output_b.decode(errors='ignore') async def read_interactive_stream() -> Optional[str]: buffer = b''