o 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 z t|jdWntytd|jw|dur|n|j}t}|dur2|dkr2||7} z t|j|j WdSt yt |jj }|dkrSYdS|durut|krut |j|dkrntd|jtd|jt|dur|dpd Ynwq3) Nwbzfailed to create %srTz&Timeout waiting to acquire lock for %sz%s is already locked g?)open unique_namecloseIOErrorrtimeouttimeoslink lock_fileOSErrorstatst_nlinkunlinkrpathr sleep)selfrend_timenlinksr 7/usr/lib/python3/dist-packages/lockfile/linklockfile.pyacquires:   zLinkLockFile.acquirecCsN|s td|jtj|jstd|jt|jt|jdS)Nz%s is not lockedz%s is locked, but not by me) is_lockedrrrexistsrrrrrr r r!release7s  zLinkLockFile.releasecCstj|jSN)rrr$rr%r r r!r#?szLinkLockFile.is_lockedcCs(|otj|jot|jjdkS)Nr )r#rrr$rrrr%r r r! i_am_lockingBs  zLinkLockFile.i_am_lockingcCs"tj|jrt|jdSdSr')rrr$rrr%r r r! break_lockGszLinkLockFile.break_lockr') __name__ __module__ __qualname____doc__r"r&r#r(r)r r r r!r s & r ) __future__rrrrrrrrr r r r r r!s