Skip to contentSkip to conversation

oeqa/targetcontrol: Rework exception handling to avoid warnings

PATCH New Richard Purdie 1 participant 1 message Jun 3, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 oeqa/targetcontrol: Rework exception handling to avoid warnings

We're seeing:

WARNING: bitbake/lib/bb/cookerdata.py:136: ResourceWarning: unclosed file <_io.FileIO name='tmp/work/qemux86_64-poky-linux/core-image-minimal/1.0-r0/testimage/qemurunner_log.20200601181912' mode='ab' closefd=True

which can only be caused by the qemu.stop() method not being called. Tweak the error handling to fix the blanket exception handler which is likely meaning this function isn't getting called.

---
 meta/lib/oeqa/targetcontrol.py  | 5 ++++-
 meta/lib/oeqa/utils/commands.py | 5 +----
 2 files changed, 5 insertions(+), 5 deletions(-)
meta/lib/oeqa/targetcontrol.py +4 -1
index 2aa548e1ad2..7bbba6016b2 100644
@@ -182,7 +182,10 @@ class QemuTarget(BaseTarget):
         return self.runner.is_alive()
 
     def stop(self):
-        self.runner.stop()
+        try:
+            self.runner.stop()
+        except:
+            pass
         self.logger.removeHandler(self.loggerhandler)
         self.connection = None
         self.ip = None
meta/lib/oeqa/utils/commands.py +1 -4
index f1679875dc2..df373c41696 100644
@@ -351,10 +351,7 @@ def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None, launch_cmd=None,
 
     finally:
         targetlogger.removeHandler(handler)
-        try:
-            qemu.stop()
-        except:
-            pass
+        qemu.stop()
 
 def updateEnv(env_file):
     """
Signature · 1 line
2.25.1