U UV\ @sPddlmZddlZddlZddlmZmZmZmZm Z m Z GdddeZ dS))absolute_importN)LockBase LockFailed NotLocked NotMyLock LockTimeout AlreadyLockedc@s:eZdZdZd ddZddZddZd d Zd d ZdS) LinkLockFilezLock access to a file using atomic property of link(2). >>> lock = LinkLockFile('somefile') >>> lock = LinkLockFile('somefile', threaded=False) NcCs zt|jdWn"tk r6td|jYnX|dk rD|n|j}t}|dk rj|dkrj||7}zt|j|j Wnt k rt |jj }|dkrYdS|dk rt|krt |j|dkrtd|jntd|jt|dk r |dp dYqjXdSqjdS) Nwbzfailed to create %srz&Timeout waiting to acquire lock for %sz%s is already locked g?)open unique_namecloseIOErrorrtimeouttimeoslink lock_fileOSErrorstatst_nlinkunlinkrpathr sleep)selfrend_timeZnlinksrF/opt/alt/python38/lib/python3.8/site-packages/lockfile/linklockfile.pyacquires2 $zLinkLockFile.acquirecCsP|std|jntj|js4td|jt|jt|jdS)Nz%s is not lockedz%s is locked, but not by me) is_lockedrrrexistsrrrrrrrr release7s  zLinkLockFile.releasecCstj|jSN)rrr#rr$rrr r"?szLinkLockFile.is_lockedcCs(|o&tj|jo&t|jjdkS)Nr )r"rrr#rrrr$rrr i_am_lockingBs  zLinkLockFile.i_am_lockingcCstj|jrt|jdSr&)rrr#rrr$rrr break_lockGszLinkLockFile.break_lock)N) __name__ __module__ __qualname____doc__r!r%r"r'r(rrrr r s  &r ) __future__rrrrrrrrr r rrrr s