fix: set sufficient buffer limit for idf.py confserver

This commit is contained in:
Jan Beran
2025-12-16 12:11:05 +01:00
parent 23aa2ad613
commit 0d23a33678
2 changed files with 112 additions and 19 deletions
+44 -10
View File
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
import asyncio
import importlib
@@ -278,9 +278,20 @@ def fit_text_in_terminal(out: str) -> str:
class RunTool:
def __init__(self, tool_name: str, args: List, cwd: str, env: Optional[Dict]=None, custom_error_handler: Optional[FunctionType]=None,
build_dir: Optional[str]=None, hints: bool=True, force_progression: bool=False, interactive: bool=False, convert_output: bool=False
) -> None:
def __init__(
self,
tool_name: str,
args: list,
cwd: str,
env: Optional[Dict] = None,
custom_error_handler: Optional[FunctionType] = None,
build_dir: Optional[str] = None,
hints: bool = True,
force_progression: bool = False,
interactive: bool = False,
convert_output: bool = False,
buffer_size: Optional[int] = None,
) -> None:
self.tool_name = tool_name
self.args = args
self.cwd = cwd
@@ -292,6 +303,7 @@ class RunTool:
self.force_progression = force_progression
self.interactive = interactive
self.convert_output = convert_output
self.buffer_size = buffer_size or 256
def __call__(self) -> None:
def quote_arg(arg: str) -> str:
@@ -342,8 +354,14 @@ class RunTool:
# Note: we explicitly pass in os.environ here, as we may have set IDF_PATH there during startup
# limit was added for avoiding error in idf.py confserver
try:
p = await asyncio.create_subprocess_exec(*cmd, env=env_copy, limit=1024 * 256, cwd=self.cwd, stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE)
p = await asyncio.create_subprocess_exec(
*cmd,
env=env_copy,
limit=1024 * self.buffer_size,
cwd=self.cwd,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
)
except NotImplementedError:
message = f'ERROR: {sys.executable} doesn\'t support asyncio. The issue can be worked around by re-running idf.py with the "--no-hints" argument.'
if sys.platform == 'win32':
@@ -472,8 +490,15 @@ def run_tool(*args: Any, **kwargs: Any) -> None:
return RunTool(*args, **kwargs)()
def run_target(target_name: str, args: 'PropertyDict', env: Optional[Dict]=None,
custom_error_handler: Optional[FunctionType]=None, force_progression: bool=False, interactive: bool=False) -> None:
def run_target(
target_name: str,
args: 'PropertyDict',
env: Optional[Dict] = None,
custom_error_handler: Optional[FunctionType] = None,
force_progression: bool = False,
interactive: bool = False,
buffer_size: Optional[int] = None,
) -> None:
"""Run target in build directory."""
if env is None:
env = {}
@@ -490,8 +515,17 @@ def run_target(target_name: str, args: 'PropertyDict', env: Optional[Dict]=None,
if 'CLICOLOR_FORCE' not in env:
env['CLICOLOR_FORCE'] = '1'
RunTool(generator_cmd[0], generator_cmd + [target_name], args.build_dir, env, custom_error_handler, hints=not args.no_hints,
force_progression=force_progression, interactive=interactive)()
RunTool(
generator_cmd[0],
generator_cmd + [target_name],
args.build_dir,
env,
custom_error_handler,
hints=not args.no_hints,
force_progression=force_progression,
interactive=interactive,
buffer_size=buffer_size,
)()
def _strip_quotes(value: str, regexp: re.Pattern=re.compile(r"^\"(.*)\"$|^'(.*)'$|^(.*)$")) -> Optional[str]: