Skip to content

Commit 6a361c5

Browse files
committed
Use subprocess.run instead of os.system to speedup.
1 parent 2353301 commit 6a361c5

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

graph_net/torch/sample_passes/agent_unittest_generator.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import re
2-
import os
32
import sys
3+
import subprocess
44
import ast
55
import inspect
66
import jinja2
@@ -204,8 +204,11 @@ def _try_to_run_unittest(self, unittest):
204204

205205
with tempfile.TemporaryDirectory(prefix="unittest_") as temp_dir:
206206
output_path = self._write_to_file(unittest, temp_dir)
207-
cmd = f"{sys.executable} {output_path}"
208-
return os.system(cmd) == 0
207+
result = subprocess.run(
208+
[sys.executable, output_path],
209+
check=True,
210+
)
211+
return result.returncode == 0
209212

210213
def _get_input_and_weight_arg_names(self, graph_module):
211214
input_arg_names = []

0 commit comments

Comments
 (0)