]> code.ossystems Code Review - openembedded-core.git/commitdiff
oeqa/utils/commands: Avoid unclosed file warnings
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 13 Nov 2018 22:43:25 +0000 (22:43 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 6 Dec 2018 10:30:04 +0000 (10:30 +0000)
Avoid warnings such as:

meta/lib/oeqa/utils/commands.py:213: ResourceWarning: unclosed file <_io.BufferedReader name=4>
  return runCmd(cmd, ignore_status, timeout, output_log=output_log, **options)

(From OE-Core rev: 6a68c42de08cffbadb59ebda63fa5e19f6e5acef)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/lib/oeqa/utils/commands.py

index da705295bc7677bf95645197b0931cbfe7982100..2e6a2289cd988a78ee4c77171d136ce42ad35a1e 100644 (file)
@@ -146,6 +146,9 @@ class Command(object):
         # At this point we know that the process has closed stdout/stderr, so
         # it is safe and necessary to wait for the actual process completion.
         self.status = self.process.wait()
+        self.process.stdout.close()
+        if self.process.stderr:
+            self.process.stderr.close()
 
         self.log.debug("Command '%s' returned %d as exit code." % (self.cmd, self.status))
         # logging the complete output is insane