diff options
author | Davanum Srinivas <davanum@gmail.com> | 2015-09-07 19:35:30 -0400 |
---|---|---|
committer | Davanum Srinivas <davanum@gmail.com> | 2015-09-07 19:35:34 -0400 |
commit | 6e9888d592f92319c63ccbd86ea61db32076ae1c (patch) | |
tree | ea57a71d08c48ff15b67ad5996712fbe6b3a8b30 | |
parent | 0c970a6564aab9080aab64bac0d3f01993c871bc (diff) | |
download | lockfile-6e9888d592f92319c63ccbd86ea61db32076ae1c.tar.gz |
Fix PIDLockFile.acquire() may loop indefinitely
end_time takes timeout into account, so when time.time()
does hit the end_time, we should check if timeout was
set or not and throw either LockTimeout or AlreadyLocked.
Closes-Bug: #1472101
Change-Id: I1f369628e765a173ff0cafd01c31eca725b41cae
-rw-r--r-- | lockfile/pidlockfile.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lockfile/pidlockfile.py b/lockfile/pidlockfile.py index 6d042d7..c4c8a39 100644 --- a/lockfile/pidlockfile.py +++ b/lockfile/pidlockfile.py @@ -81,8 +81,8 @@ class PIDLockFile(LockBase): except OSError as exc: if exc.errno == errno.EEXIST: # The lock creation failed. Maybe sleep a bit. - if timeout is not None and time.time() > end_time: - if timeout > 0: + if time.time() > end_time: + if timeout is not None and timeout > 0: raise LockTimeout("Timeout waiting to acquire" " lock for %s" % self.path) |