Skip to content

Commit 1b3c83c

Browse files
committed
Revert subprocess changes in file.py - use subprocess.run instead of manual Popen
1 parent 2a0682a commit 1b3c83c

File tree

1 file changed

+1
-25
lines changed

1 file changed

+1
-25
lines changed

codeflash/verification/test_runner.py

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,7 @@ def execute_test_subprocess(
2525
"""Execute a subprocess with the given command list, working directory, environment variables, and timeout."""
2626
with custom_addopts():
2727
logger.debug(f"executing test run with command: {' '.join(cmd_list)}")
28-
# Use explicit pipe management to prevent FD leaks
29-
proc = subprocess.Popen(
30-
cmd_list, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, cwd=cwd, env=env, text=True
31-
)
32-
try:
33-
stdout, stderr = proc.communicate(timeout=timeout)
34-
returncode = proc.returncode
35-
except subprocess.TimeoutExpired:
36-
proc.kill()
37-
try:
38-
stdout, stderr = proc.communicate(timeout=5)
39-
except subprocess.TimeoutExpired:
40-
proc.terminate()
41-
stdout, stderr = "", "Process terminated due to timeout"
42-
returncode = -1
43-
finally:
44-
# Ensure all pipes are closed
45-
if proc.stdin:
46-
proc.stdin.close()
47-
if proc.stdout:
48-
proc.stdout.close()
49-
if proc.stderr:
50-
proc.stderr.close()
51-
52-
return subprocess.CompletedProcess(cmd_list, returncode, stdout, stderr)
28+
return subprocess.run(cmd_list, capture_output=True, cwd=cwd, env=env, text=True, timeout=timeout, check=False)
5329

5430

5531
def run_behavioral_tests(

0 commit comments

Comments
 (0)