aboutsummaryrefslogtreecommitdiffstats
path: root/build_scripts/utils.py
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2022-01-05 16:24:24 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2022-01-05 17:46:25 +0100
commit5925ccb54b818e9dfc0766480683d232f95e6965 (patch)
tree461c765ea3e97eac4744be90ff124fa96adab1a0 /build_scripts/utils.py
parentd7526db85fcec588fa6ca643bd6fb8a9f45c3fc2 (diff)
build_scripts: Ensure cmake process terminates
Use a context manager to fix warning: c:\Python310\lib\subprocess.py:1067: ResourceWarning: subprocess 7844 is still running _warn("subprocess %s is still running" % self.pid, ResourceWarning: Enable tracemalloc to get the object allocation traceback Pick-to: 6.2 Change-Id: I6e3ebf584974f8a2d3776847b13fe092d3d4be4a Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'build_scripts/utils.py')
-rw-r--r--build_scripts/utils.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/build_scripts/utils.py b/build_scripts/utils.py
index 3aca642ce..39cff6743 100644
--- a/build_scripts/utils.py
+++ b/build_scripts/utils.py
@@ -405,13 +405,12 @@ def rmtree(dirname, ignore=False):
def run_process_output(args, initial_env=None):
if initial_env is None:
initial_env = os.environ
- std_out = subprocess.Popen(args, env=initial_env, universal_newlines=1,
- stdout=subprocess.PIPE).stdout
result = []
- for raw_line in std_out.readlines():
- line = raw_line
- result.append(line.rstrip())
- std_out.close()
+ with subprocess.Popen(args, env=initial_env, universal_newlines=1,
+ stdout=subprocess.PIPE) as p:
+ for raw_line in p.stdout.readlines():
+ result.append(raw_line.rstrip())
+ p.stdout.close()
return result