mirror of
https://github.com/esphome/esphome.git
synced 2025-09-04 20:32:21 +01:00
Optimize subprocess performance with close_fds=False (#10145)
This commit is contained in:
@@ -31,7 +31,11 @@ def run_format(executable, args, queue, lock, failed_files):
|
||||
invocation.append(path)
|
||||
|
||||
proc = subprocess.run(
|
||||
invocation, capture_output=True, encoding="utf-8", check=False
|
||||
invocation,
|
||||
capture_output=True,
|
||||
encoding="utf-8",
|
||||
check=False,
|
||||
close_fds=False,
|
||||
)
|
||||
if proc.returncode != 0:
|
||||
with lock:
|
||||
|
@@ -158,7 +158,11 @@ def run_tidy(executable, args, options, tmpdir, path_queue, lock, failed_files):
|
||||
invocation.extend(options)
|
||||
|
||||
proc = subprocess.run(
|
||||
invocation, capture_output=True, encoding="utf-8", check=False
|
||||
invocation,
|
||||
capture_output=True,
|
||||
encoding="utf-8",
|
||||
check=False,
|
||||
close_fds=False,
|
||||
)
|
||||
if proc.returncode != 0:
|
||||
with lock:
|
||||
@@ -320,9 +324,11 @@ def main():
|
||||
print("Applying fixes ...")
|
||||
try:
|
||||
try:
|
||||
subprocess.call(["clang-apply-replacements-18", tmpdir])
|
||||
subprocess.call(
|
||||
["clang-apply-replacements-18", tmpdir], close_fds=False
|
||||
)
|
||||
except FileNotFoundError:
|
||||
subprocess.call(["clang-apply-replacements", tmpdir])
|
||||
subprocess.call(["clang-apply-replacements", tmpdir], close_fds=False)
|
||||
except FileNotFoundError:
|
||||
print(
|
||||
"Error please install clang-apply-replacements-18 or clang-apply-replacements.\n",
|
||||
|
@@ -55,4 +55,6 @@ for section in config.sections():
|
||||
tools.append("-t")
|
||||
tools.append(tool)
|
||||
|
||||
subprocess.check_call(["platformio", "pkg", "install", "-g", *libs, *platforms, *tools])
|
||||
subprocess.check_call(
|
||||
["platformio", "pkg", "install", "-g", *libs, *platforms, *tools], close_fds=False
|
||||
)
|
||||
|
@@ -13,7 +13,7 @@ def find_and_activate_virtualenv():
|
||||
try:
|
||||
# Get the top-level directory of the git repository
|
||||
my_path = subprocess.check_output(
|
||||
["git", "rev-parse", "--show-toplevel"], text=True
|
||||
["git", "rev-parse", "--show-toplevel"], text=True, close_fds=False
|
||||
).strip()
|
||||
except subprocess.CalledProcessError:
|
||||
print(
|
||||
@@ -44,7 +44,7 @@ def find_and_activate_virtualenv():
|
||||
def run_command():
|
||||
# Execute the remaining arguments in the new environment
|
||||
if len(sys.argv) > 1:
|
||||
subprocess.run(sys.argv[1:], check=False)
|
||||
subprocess.run(sys.argv[1:], check=False, close_fds=False)
|
||||
else:
|
||||
print(
|
||||
"No command provided to run in the virtual environment.",
|
||||
|
Reference in New Issue
Block a user