From cdba960d1dd6a02ee01e3b7a9865fec255aed0cd Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Fri, 24 Sep 2021 17:55:09 +0100 Subject: [PATCH] use with subprocess to get it to close Popen files --- src/openpower/simulator/program.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/openpower/simulator/program.py b/src/openpower/simulator/program.py index c2b4adbe..a3dd3754 100644 --- a/src/openpower/simulator/program.py +++ b/src/openpower/simulator/program.py @@ -88,12 +88,12 @@ class Program: self.obj_fmt, "-o", outfile.name] - p = subprocess.Popen(args, stdin=subprocess.PIPE) - p.communicate(self.assembly.encode('utf-8')) - if p.wait() != 0: - print("Error in program:") - print(self.assembly) - sys.exit(1) + with subprocess.Popen(args, stdin=subprocess.PIPE) as p: + p.communicate(self.assembly.encode('utf-8')) + if p.wait() != 0: + print("Error in program:") + print(self.assembly) + sys.exit(1) self._link(outfile) def _get_instructions(self): -- 2.30.2