efddlmZmZddlZddlZ en #e$reZYnwxYwddlm Z m Z m Z m Z m Z Gdde ZdS))absolute_importdivisionN)LockBase NotLocked NotMyLock LockTimeout AlreadyLockedcDeZdZdZdZd dZd dZdZdZdZ d Z d Z dS) SQLiteLockFilezDemonstrate SQL-based locking.NTctj||||t|j|_t|j|_t jQddl}|\}}tj |tj |~~|t _ddl }| t j|_|j} |d|jddl} | tj t jdS#|j$rYdSwxYw)zu >>> lock = SQLiteLockFile('somefile') >>> lock = SQLiteLockFile('somefile', threaded=False) NrzGcreate table locks( lock_file varchar(32), unique_name varchar(32)))r__init__unicode lock_file unique_namer testdbtempfilemkstemposcloseunlinksqlite3connect connectioncursorexecutecommitatexitregisterOperationalError) selfpaththreadedtimeoutr_fdrrcrs w/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/lockfile/sqlitelockfile.pyrzSQLiteLockFile.__init__sG $h888 00"4#344  ( OOO"**,,KC HSMMM If   X$*N !!//.*?@@ O " " $ $ > II    O " " $ $ $ MMM OOBI~'< = = = = = '    DD s)E EEc||n|j}tj}| |dkr||z }|d}n|dkrd}n|dz }|j} |s|d|j|jf|j|d|jf| }t|dkr6|d|jf|jnGdS|d|jf| }t|dkrdS|Ktj|kr4|dkrtd |j ztd |j ztj|r) Nrg? Tz;insert into locks (lock_file, unique_name) values (?, ?)z*select * from locks where unique_name = ?r(delete from locks where unique_name = ?z&Timeout waiting to acquire lock for %sz%s is already locked)r$timerr is_lockedrrrrfetchalllenr r"r sleep)r!r$end_timewaitrrowss r'acquirezSQLiteLockFile.acquire5s$0''dl9;;  7Q;;  H ?DD \\DDR>##  *!%0@A CCC &&((( 9 $ 02444((t99q==NN$=$($4#6888O**,,,,F 9 $ 02444((t99>>F"ty{{X'='=Q;;%'5&*i'0111 ((>(JKKK Jt   ]. cx|std|jz|s,t |jd|d|j}| d|jf|j dS)Nz%s is not lockedz is locked, but not by me (by )r*) r,rr" i_am_lockingrr_who_is_lockingrrrrr!rs r'releasezSQLiteLockFile.releasets~~ <.:;; ;  "" H!---t/C/C/E/E/E/EGHH H''))1(* , , ,      r4c|j}|d|jf|dS)Nz2select unique_name from locks where lock_file = ?r)rrrrfetchoner9s r'r8zSQLiteLockFile._who_is_lockingsO''))/( * * *  ##r4c|j}|d|jf|}| S)Nz(select * from locks where lock_file = ?)rrrrr-)r!rr2s r'r,zSQLiteLockFile.is_lockedsS''))/( * * *  8|r4c|j}|d|j|jf| S)Nz?select * from locks where lock_file = ? and unique_name = ?)rrrrrr-r9s r'r7zSQLiteLockFile.i_am_lockingsW''))1(89 ; ; ;(((((r4c|j}|d|jf|jdS)Nz&delete from locks where lock_file = ?)rrrrrr9s r' break_lockzSQLiteLockFile.break_locksT''))/( * * *      r4)TN)N) __name__ __module__ __qualname____doc__rrr3r:r8r,r7r@r4r'r r s$$ F > > > >D====~ ! ! !$$$)))!!!!!r4r ) __future__rrr+rr NameErrorstrrrrr r r rEr4r'rJs00000000  GGGGGIHHHHHHHHHHHHHN!N!N!N!N!XN!N!N!N!N!s