[PATCH 5/6] utils: Add lockfile_to_exclusive
Richard Purdie <[email protected]>
| Newsgroups | org.openembedded.lists.bitbake-devel |
|---|---|
| Message-ID | <[email protected]> |
Add a function which turns a shared lock into an exclusive lock. This is useful for planned changes to the fetcher code. Signed-off-by: Richard Purdie <[email protected]> --- lib/bb/utils.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/bb/utils.py b/lib/bb/utils.py index 92b60b39d2c..b635f68a153 100644 --- a/lib/bb/utils.py +++ b/lib/bb/utils.py @@ -587,6 +587,13 @@ def lockfile(name, shared=False, retry=True, block=False): if not retry: return None +def lockfile_to_exclusive(lf): + if not lf: + return + fileno = lf.fileno() + fcntl.flock(fileno, fcntl.LOCK_EX) + return + def unlockfile(lf): """ Unlock a file locked using ``bb.utils.lockfile()``.