Merge pull request #21 from harlowja/sanity-check

Add sanity __enter__ acquire check
This commit is contained in:
Joshua Harlow 2016-01-19 12:08:31 -08:00
commit 8b63aafd5a
1 changed files with 6 additions and 1 deletions

View File

@ -176,7 +176,12 @@ class _InterProcessLock(object):
self.lockfile = None
def __enter__(self):
self.acquire()
gotten = self.acquire()
if not gotten:
# This shouldn't happen, but just incase...
raise threading.ThreadError("Unable to acquire a file lock"
" on `%s` (when used as a"
" context manager)" % self.path)
return self
def release(self):