Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
3 ÝPf›$ã @s„dZddlmZddlZddlZddlZddlZddlZeedƒsJej e_ eej dƒsbej j ej _ dddd d d d d dddddg ZGdd„deƒZGdd„deƒZGdd„deƒZGdd „d eƒZGdd „d eƒZGdd „d eƒZGdd „d eƒZGdd „d eƒZGdd„deƒZGdd„deƒZdd„Zd d„Zd!d„Zd"d„Zd(d#d„Zeed$ƒ�rjd%d&l m!Z"e"j#Z$nd%d'l m%Z&e&j'Z$e$Z(dS))a lockfile.py - Platform-independent advisory file locks. Requires Python 2.5 unless you apply 2.4.diff Locking is done on a per-thread basis instead of a per-process basis. Usage: >>> lock = LockFile('somefile') >>> try: ... lock.acquire() ... except AlreadyLocked: ... print 'somefile', 'is locked already.' ... except LockFailed: ... print 'somefile', 'can\'t be locked.' ... else: ... print 'got lock' got lock >>> print lock.is_locked() True >>> lock.release() >>> lock = LockFile('somefile') >>> print lock.is_locked() False >>> with lock: ... print lock.is_locked() True >>> print lock.is_locked() False >>> lock = LockFile('somefile') >>> # It is okay to lock twice from the same thread... >>> with lock: ... lock.acquire() ... >>> # Though no counter is kept, so you can't unlock multiple times... >>> print lock.is_locked() False Exceptions: Error - base class for other exceptions LockError - base class for all locking exceptions AlreadyLocked - Another thread or process already holds the lock LockFailed - Lock failed for some other reason UnlockError - base class for all unlocking exceptions AlreadyUnlocked - File was not locked. NotMyLock - File was locked but not by the current thread/process é)Úabsolute_importNÚcurrent_threadÚget_nameÚErrorÚ LockErrorÚ LockTimeoutÚ AlreadyLockedÚ LockFailedÚ UnlockErrorÚ NotLockedÚ NotMyLockÚ LinkFileLockÚ MkdirFileLockÚSQLiteFileLockÚLockBaseÚlockedc@seZdZdZdS)rzw Base class for other exceptions. >>> try: ... raise Error ... except Exception: ... pass N)Ú__name__Ú __module__Ú __qualname__Ú__doc__©rrú/usr/lib/python3.6/__init__.pyrJsc@seZdZdZdS)rz– Base class for error arising from attempts to acquire the lock. >>> try: ... raise LockError ... except Error: ... pass N)rrrrrrrrrVsc@seZdZdZdS)rz�Raised when lock creation fails within a user-defined period of time. >>> try: ... raise LockTimeout ... except LockError: ... pass N)rrrrrrrrrbsc@seZdZdZdS)rzˆSome other thread/process is locking the file. >>> try: ... raise AlreadyLocked ... except LockError: ... pass N)rrrrrrrrrmsc@seZdZdZdS)r z‡Lock file creation failed for some other reason. >>> try: ... raise LockFailed ... except LockError: ... pass N)rrrrrrrrr xsc@seZdZdZdS)r z™ Base class for errors arising from attempts to release the lock. >>> try: ... raise UnlockError ... except Error: ... pass N)rrrrrrrrr ƒsc@seZdZdZdS)r z’Raised when an attempt is made to unlock an unlocked file. >>> try: ... raise NotLocked ... except UnlockError: ... pass N)rrrrrrrrr �sc@seZdZdZdS)r zœRaised when an attempt is made to unlock a file someone else locked. >>> try: ... raise NotMyLock ... except UnlockError: ... pass N)rrrrrrrrr šsc@s>eZdZdd„Zddd„Zdd„Zdd „Zd d „Zd d „ZdS)Ú _SharedBasecCs ||_dS)N)Úpath)ÚselfrrrrÚ__init__¦sz_SharedBase.__init__NcCs tdƒ‚dS)a� Acquire the lock. * If timeout is omitted (or None), wait forever trying to lock the file. * If timeout > 0, try to acquire the lock for that many seconds. If the lock period expires and the file is still locked, raise LockTimeout. * If timeout <= 0, raise AlreadyLocked immediately if the file is already locked. zimplement in subclassN)ÚNotImplemented)rÚtimeoutrrrÚacquire©sz_SharedBase.acquirecCs tdƒ‚dS)zX Release the lock. If the file is not locked, raise NotLocked. zimplement in subclassN)r)rrrrÚrelease¹sz_SharedBase.releasecCs |jƒ|S)z* Context manager support. )r)rrrrÚ __enter__Ász_SharedBase.__enter__cGs |jƒdS)z* Context manager support. N)r)rZ_excrrrÚ__exit__Èsz_SharedBase.__exit__cCsd|jj|jfS)Nz<%s: %r>)Ú __class__rr)rrrrÚ__repr__Îsz_SharedBase.__repr__)N) rrrrrrr r!r#rrrrr¥s  rcsBeZdZdZd‡fdd„ Zdd„Zdd „Zd d „Zd d „Z‡Z S)rz.Base class for platform-specific lock classes.TNcs¨tt|ƒj|ƒtjj|ƒd|_tjƒ|_ tj ƒ|_ |rbt j ƒ}t|dt|ƒƒ}d|d@|_nd|_tjj|jƒ}tjj|d|j |j|j t|jƒfƒ|_||_dS)zi >>> lock = LockBase('somefile') >>> lock = LockBase('somefile', threaded=False) z.lockÚidentz-%xlÿÿÚz %s%s.%s%sN)ÚsuperrrÚosrÚabspathZ lock_fileÚsocketZ gethostnameZhostnameÚgetpidÚpidÚ threadingrÚgetattrÚhashZtnameÚdirnameÚjoinÚ unique_namer)rrÚthreadedrÚtr$r/)r"rrrÔs    zLockBase.__init__cCs tdƒ‚dS)z9 Tell whether or not the file is locked. zimplement in subclassN)r)rrrrÚ is_lockedõszLockBase.is_lockedcCs tdƒ‚dS)zA Return True if this object is locking the file. zimplement in subclassN)r)rrrrÚ i_am_lockingûszLockBase.i_am_lockingcCs tdƒ‚dS)zN Remove a lock. Useful if a locking thread failed to unlock. zimplement in subclassN)r)rrrrÚ break_lockszLockBase.break_lockcCsd|jj|j|jfS)Nz<%s: %r -- %r>)r"rr1r)rrrrr#s zLockBase.__repr__)TN) rrrrrr4r5r6r#Ú __classcell__rr)r"rrÒs !cOsRtjd|tdd�t|dtƒs.|dd…}t|ƒdkrH| rHd|d<|||ŽS)Nz1Import from %s module instead of lockfile packageé)Ú stacklevelréTr2)ÚwarningsÚwarnÚDeprecationWarningÚ isinstanceÚstrÚlen)ÚclsÚmodÚargsÚkwdsrrrÚ _fl_helper s   rEcOs ddlm}t|jdf|ž|ŽS)z¡Factory function provided for backwards compatibility. Do not use in new code. Instead, import LinkLockFile from the lockfile.linklockfile module. r:)Ú linklockfilezlockfile.linklockfile)r%rFrEÚ LinkLockFile)rCrDrFrrrr s  cOs ddlm}t|jdf|ž|ŽS)z£Factory function provided for backwards compatibility. Do not use in new code. Instead, import MkdirLockFile from the lockfile.mkdirlockfile module. r:)Ú mkdirlockfilezlockfile.mkdirlockfile)r%rHrEÚ MkdirLockFile)rCrDrHrrrr%s  cOs ddlm}t|jdf|ž|ŽS)z¤Factory function provided for backwards compatibility. Do not use in new code. Instead, import SQLiteLockFile from the lockfile.mkdirlockfile module. r:)Úsqlitelockfilezlockfile.sqlitelockfile)r%rJrEZSQLiteLockFile)rCrDrJrrrr0s  cs‡‡fdd„}|S)aDecorator which enables locks for decorated function. Arguments: - path: path for lockfile. - timeout (optional): Timeout for acquiring lock. Usage: @locked('/var/run/myname', timeout=0) def myname(...): ... cstjˆƒ‡‡‡fdd„ƒ}|S)Nc s.tˆˆd�}|jƒz ˆ||ŽS|jƒXdS)N)r)ÚFileLockrr)rCÚkwargsÚlock)ÚfuncrrrrÚwrapperHs   z&locked..decor..wrapper)Ú functoolsÚwraps)rNrO)rr)rNrÚdecorGszlocked..decorr)rrrRr)rrrr;s  Úlinkr:)rF)rH)N))rZ __future__rrPr'r)r,r;ÚhasattrZ currentThreadrZThreadZgetNamerÚ__all__Ú Exceptionrrrrr r r r ÚobjectrrrEr rrrr%rFZ_llfrGZLockFilerHZ_mlfrIrKrrrrÚ4sF            -: