[oe-commits] [bitbake] 09/25: bb.utils.fileslocked: don't leak files if yield throws

git at git.openembedded.org git at git.openembedded.org
Sat Jan 11 11:07:05 UTC 2020


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch 1.44
in repository bitbake.

commit 81829ab28afae08e02f4a758ec063fc0d90579ea
Author: Chris Laplante via bitbake-devel <bitbake-devel at lists.openembedded.org>
AuthorDate: Tue Dec 10 14:10:20 2019 -0500

    bb.utils.fileslocked: don't leak files if yield throws
    
    Discovered with a recipe under devtool. The ${S}/singletask.lock file (added by
    externalsrc.bbclass) was leaked, giving a warning like:
    
      WARNING: <PN>+git999-r0 do_populate_lic: /home/laplante/yocto/sources/poky/bitbake/lib/bb/build.py:582: ResourceWarning: unclosed file <_io.TextIOWrapper name='/home/laplante/yocto/build/workspace/sources/<PN>/singletask.lock' mode='a+' encoding='UTF-8'>
        exec_func(task, localdata)
    
    Signed-off-by: Chris Laplante <chris.laplante at agilent.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
    (cherry picked from commit 6beddf6214e22b4002626761031a9e9d34fb04db)
---
 lib/bb/utils.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index 8d40bcd..d65265c 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -428,10 +428,11 @@ def fileslocked(files):
         for lockfile in files:
             locks.append(bb.utils.lockfile(lockfile))
 
-    yield
-
-    for lock in locks:
-        bb.utils.unlockfile(lock)
+    try:
+        yield
+    finally:
+        for lock in locks:
+            bb.utils.unlockfile(lock)
 
 @contextmanager
 def timeout(seconds):

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list