On knotty, Make sure bitbake.lock is unlocked before exiting
cover On knotty, Make sure bitbake.lock is unlocked before exiting
From: Leonardo Sandoval <[email protected]>
Solves issues recently found on the AutoBuilder, where between one build and another the following log error is seen:
ERROR: Only one copy of bitbake should be run against a build directory
More info on https://bugzilla.yoctoproject.org/show_bug.cgi?id=7941
The following changes since commit b78b1a6bb82fb864f1f857bf7259908d0ed930b5:
tune-i586-nlp: Add new tune file to support Quark/X1000 CPU (2015-07-01 15:40:00 +0100)
are available in the git repository at:
git://git.yoctoproject.org/poky-contrib lsandov1/PR-Service-selftest-failures-7941
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=lsandov1/PR-Service-selftest-failures-7941
Leonardo Sandoval (3):
cooker.py: Lock/Unlock members function into BBCooker command.py: Unlock function included into CommandsSync class knotty.py: Make sure bitbake.lock is unlocked before exiting
bitbake/lib/bb/command.py | 6 ++++++ bitbake/lib/bb/cooker.py | 17 ++++++++++++++--- bitbake/lib/bb/ui/knotty.py | 20 ++++++++++++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-)
Signature · 1 line
1.8.4.5
PATCH 1/3 cooker.py: Lock/Unlock members function into BBCooker
From: Leonardo Sandoval <[email protected]>
--- bitbake/lib/bb/cooker.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
bitbake/lib/bb/cooker.py +14 -3
@@ -151,9 +151,7 @@ class BBCooker: # Take a lock so only one copy of bitbake can run against a given build # directory at a time - lockfile = self.data.expand("${TOPDIR}/bitbake.lock") - self.lock = bb.utils.lockfile(lockfile, False, False) - if not self.lock: + if not self.lockBitbake(): bb.fatal("Only one copy of bitbake should be run against a build directory") try: self.lock.seek(0)
@@ -1544,6 +1542,19 @@ class BBCooker: def reset(self): self.initConfigurationData() + def lockBitbake(self): + if not hasattr(self, 'lock'): + self.lock = None + if self.data: + lockfile = self.data.expand("${TOPDIR}/bitbake.lock") + if lockfile: + self.lock = bb.utils.lockfile(lockfile, False, False) + return self.lock + + def unlockBitbake(self): + if hasattr(self, 'lock') and self.lock: + bb.utils.unlockfile(self.lock) + def server_main(cooker, func, *args): cooker.pre_serve()
Signature · 1 line
1.8.4.5
PATCH 2/3 command.py: Unlock function included into CommandsSync class
In reply to [email protected]From: Leonardo Sandoval <[email protected]>
Function which calls cooker's unlock method, which in turn unlocks bitbake.lock file.
--- bitbake/lib/bb/command.py | 6 ++++++ 1 file changed, 6 insertions(+)
bitbake/lib/bb/command.py +6 -0
@@ -267,6 +267,12 @@ class CommandsSync: features = params[0] command.cooker.setFeatures(features) + def unlockBitbake(self, command, params): + """ + Unlock bitbake.lock file + """ + command.cooker.unlockBitbake() + # although we change the internal state of the cooker, this is transparent since # we always take and leave the cooker in state.initial setFeatures.readonly = True
Signature · 1 line
1.8.4.5
PATCH 3/3 knotty.py: Make sure bitbake.lock is unlocked before exiting
In reply to [email protected]From: Leonardo Sandoval <[email protected]>
Before exiting the UI, unlocks the bitbake.lock owned by cooker; this way consecutive bitbake executions can lock it again without trouble.
[Yocto #7941]
--- bitbake/lib/bb/ui/knotty.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
bitbake/lib/bb/ui/knotty.py +20 -0
@@ -310,6 +310,7 @@ def main(server, eventHandler, params, tf = TerminalFilter): errors = 0 warnings = 0 taskfailures = [] + locktries = 10 termfilter = tf(main, helper, console, errconsole, format) atexit.register(termfilter.finish)
@@ -537,6 +538,25 @@ def main(server, eventHandler, params, tf = TerminalFilter): _, error = server.runCommand(["stateForceShutdown"]) main.shutdown = 2 try: + topdir, error = server.runCommand(["getVariable", "TOPDIR"]) + if error: + logger.warn("Unable to get the value of TOPDIR variable: %s" % error) + else: + lockfile = "%s/bitbake.lock" % topdir + _, error = server.runCommand(["unlockBitbake"]) + if error: + logger.warn("Unable to unlock the file %s" % lockfile) + else: + while locktries: + lf = bb.utils.lockfile(lockfile, False, False) + if not lf: + time.sleep(1) + locktries -=1 + else: + bb.utils.unlockfile(lf) + break + if not locktries: + logger.warn("Knotty could not lock the file ${TOPDIR}/bitbake.lock, probably locked by cooker and not unlocked yet. Immediate bitbake commands may failed") summary = "" if taskfailures: summary += pluralise("\nSummary: %s task failed:",
Signature · 1 line
1.8.4.5