summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2018-11-28 16:12:51 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-12-01 11:37:49 +0000
commited80e46ccbc8fe8e9148d80723152066fa00ba28 (patch)
tree4b5ff8c4986acb70576a5c5b41fd7dce93d4ce25 /meta/lib
parent98d113ae52cbbc88773a81a17b0933412a8e463b (diff)
downloadopenembedded-core-contrib-ed80e46ccbc8fe8e9148d80723152066fa00ba28.tar.gz
openembedded-core-contrib-ed80e46ccbc8fe8e9148d80723152066fa00ba28.tar.bz2
openembedded-core-contrib-ed80e46ccbc8fe8e9148d80723152066fa00ba28.zip
oeqa/qemurunner: Remove resource python warnings
If runqemu fails it would leak an unclosed socket and file. Ensure we close these in all cases to remove the resource warning. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/utils/qemurunner.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index 241d1eced8..409e86d4bc 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -139,7 +139,7 @@ class QemuRunner:
def launch(self, launch_cmd, get_ip = True, qemuparams = None, extra_bootparams = None, env = None):
try:
- threadsock, threadport = self.create_socket()
+ self.threadsock, threadport = self.create_socket()
self.server_socket, self.serverport = self.create_socket()
except socket.error as msg:
self.logger.error("Failed to create listening socket: %s" % msg[1])
@@ -272,7 +272,7 @@ class QemuRunner:
self.logger.debug("Target IP: %s" % self.ip)
self.logger.debug("Server IP: %s" % self.server_ip)
- self.thread = LoggingThread(self.log, threadsock, self.logger)
+ self.thread = LoggingThread(self.log, self.threadsock, self.logger)
self.thread.start()
if not self.thread.connection_established.wait(self.boottime):
self.logger.error("Didn't receive a console connection from qemu. "
@@ -381,13 +381,19 @@ class QemuRunner:
self.runqemu.stdin.close()
self.runqemu.stdout.close()
self.runqemu = None
+
if hasattr(self, 'server_socket') and self.server_socket:
self.server_socket.close()
self.server_socket = None
+ if hasattr(self, 'threadsock') and self.threadsock:
+ self.threadsock.close()
+ self.threadsock = None
self.qemupid = None
self.ip = None
if os.path.exists(self.qemu_pidfile):
os.remove(self.qemu_pidfile)
+ if self.monitorpipe:
+ self.monitorpipe.close()
def stop_qemu_system(self):
if self.qemupid: