devserver: fix wait_for_status hang due to FileLock restriction
Turns out that lockfile.FileLock.release() only succeeds if the lock in
question was locked by the same thread trying to release it. This of
course is not the case with async download by different threads.
Instead, we're using break_lock(), which will remove the lock regardless
of who put it in place.
BUG=chromium-os:34684
TEST=Unit tests; installation and interactive testing of
download/wait_for_status with a live instance.
Change-Id: I6322f7d6116089b164fbb748f7544dd5f74b4496
Reviewed-on: https://gerrit.chromium.org/gerrit/33950
Commit-Ready: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
diff --git a/common_util.py b/common_util.py
index d4acccf..29a9563 100644
--- a/common_util.py
+++ b/common_util.py
@@ -406,16 +406,12 @@
raise DevServerUtilError('Invaid tag "%s".' % tag)
lock = lockfile.FileLock(os.path.join(build_dir, DEVSERVER_LOCK_FILE))
- if lock.i_am_locking():
- try:
- lock.release()
- if destroy:
- shutil.rmtree(build_dir)
- except Exception, e:
- raise DevServerUtilError(str(e))
- else:
- raise DevServerUtilError('thread attempting release is not locking %s' %
- build_dir)
+ try:
+ lock.break_lock()
+ if destroy:
+ shutil.rmtree(build_dir)
+ except Exception, e:
+ raise DevServerUtilError(str(e))
def FindMatchingBoards(static_dir, board):