aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Laplante via bitbake-devel <bitbake-devel@lists.openembedded.org>2019-12-10 14:10:20 -0500
committerArmin Kuster <akuster808@gmail.com>2019-12-17 22:12:53 -0800
commit81829ab28afae08e02f4a758ec063fc0d90579ea (patch)
tree2676964115e293363f7696dc82ea60b32e7ee1c5
parent5afad266f2ce55db2038c36f2e49a3c80be9bbfc (diff)
downloadbitbake-contrib-81829ab28afae08e02f4a758ec063fc0d90579ea.tar.gz
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@agilent.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 6beddf6214e22b4002626761031a9e9d34fb04db)
-rw-r--r--lib/bb/utils.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index 8d40bcdf8..d65265c46 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):