Export to GitHub

pylockfile - issue #28

LinkLockFile does not respect timeout=0


Posted on Apr 18, 2013 by Quick Bird

LockBase.acquire has:

    * If timeout <= 0, raise AlreadyLocked immediately if the file is
      already locked.

However, LinkLockFile.acquire treats timeout=0 the same way as timeout=None. This is because it has:

    timeout = timeout or self.timeout

and 0 or None unfortunately evaluates to None. Thus, the line should instead be changed to:

    timeout = timeout if timeout is not None else self.timeout

or I guess to support Python versions with no ternary if:

     timeout= timeout is not None and timeout or self.timeout

Comment #1

Posted on Apr 18, 2013 by Quick Bird

To fix, merge https://github.com/eallik/pylockfile/tree/issue-28 :)

Comment #2

Posted on Aug 27, 2013 by Grumpy Lion

Did it differently, and for all LockBase subclasses, not just LinkLockFile.

Status: Done

Labels:
Type-Defect Priority-Medium