summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Laplante via bitbake-devel <bitbake-devel@lists.openembedded.org>2019-12-10 14:10:20 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-01-11 11:06:22 +0000
commit7278f3f786b52b64fa3ecd7eee7b9f74428bfaf3 (patch)
tree8f048866302bc7d58801d6652d3309d1a79cfe8e
parentc37d0c4aa55f5fd703f0b9a34fe324b0a78db419 (diff)
downloadpoky-7278f3f786b52b64fa3ecd7eee7b9f74428bfaf3.tar.gz
bitbake: 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) (Bitbake rev: 81829ab28afae08e02f4a758ec063fc0d90579ea) Signed-off-by: Chris Laplante <chris.laplante@agilent.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 6beddf6214e22b4002626761031a9e9d34fb04db) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/bb/utils.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index 8d40bcdf83..d65265c461 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -428,10 +428,11 @@ def fileslocked(files):
428 for lockfile in files: 428 for lockfile in files:
429 locks.append(bb.utils.lockfile(lockfile)) 429 locks.append(bb.utils.lockfile(lockfile))
430 430
431 yield 431 try:
432 432 yield
433 for lock in locks: 433 finally:
434 bb.utils.unlockfile(lock) 434 for lock in locks:
435 bb.utils.unlockfile(lock)
435 436
436@contextmanager 437@contextmanager
437def timeout(seconds): 438def timeout(seconds):