diff options
author | Chris Laplante via bitbake-devel <bitbake-devel@lists.openembedded.org> | 2019-12-10 14:10:20 -0500 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-12-16 23:27:14 +0000 |
commit | e7f8c836f679f0d16dfa7390d58523ff473bb654 (patch) | |
tree | 370fd86ef83d6c9fff9f19f04bcaa788db40bf87 /bitbake/lib | |
parent | 1dd6edf3e4d969b3cc6918c8de6e234140ce33c9 (diff) | |
download | poky-e7f8c836f679f0d16dfa7390d58523ff473bb654.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: 6beddf6214e22b4002626761031a9e9d34fb04db)
Signed-off-by: Chris Laplante <chris.laplante@agilent.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/bb/utils.py | 9 |
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 |
437 | def timeout(seconds): | 438 | def timeout(seconds): |