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„ d Z ddlmZ ddlZddlZddlZddlZddlZeedƒsJej e_
eejdƒsbejjej_
dddd d
ddd
dddddg
ZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd „ d eƒZG dd
„ d
eƒZG dd„ deƒZG dd„ deƒZG dd
„ d
eƒZG dd„ deƒZG dd„ 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 @ s e Zd ZdZdS )r zw
Base class for other exceptions.
>>> try:
... raise Error
... except Exception:
... pass
N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r r ú/usr/lib/python3.6/__init__.pyr J s c @ s e Zd ZdZdS )r z–
Base class for error arising from attempts to acquire the lock.
>>> try:
... raise LockError
... except Error:
... pass
N)r r r r r r r r r V s c @ s e Zd ZdZdS )r z�Raised when lock creation fails within a user-defined period of time.
>>> try:
... raise LockTimeout
... except LockError:
... pass
N)r r r r r r r r r b s c @ s e Zd ZdZdS )r zˆSome other thread/process is locking the file.
>>> try:
... raise AlreadyLocked
... except LockError:
... pass
N)r r r r r r r r r m s c @ s e Zd ZdZdS )r z‡Lock file creation failed for some other reason.
>>> try:
... raise LockFailed
... except LockError:
... pass
N)r r r r r r r r r x s c @ s e Zd ZdZdS )r
z™
Base class for errors arising from attempts to release the lock.
>>> try:
... raise UnlockError
... except Error:
... pass
N)r r r r r r r r r
ƒ s c @ s e Zd ZdZdS )r z’Raised when an attempt is made to unlock an unlocked file.
>>> try:
... raise NotLocked
... except UnlockError:
... pass
N)r r r r r r r r r � s c @ s e Zd ZdZdS )r zœRaised when an attempt is made to unlock a file someone else locked.
>>> try:
... raise NotMyLock
... except UnlockError:
... pass
N)r r r r r r r r r š s c @ s> e Zd Zdd„ Zddd„Zdd„ Zdd „ Zd
d„ Zdd
„ ZdS )Ú_SharedBasec C s
|| _ d S )N)Úpath)Úselfr r r r Ú__init__¦ s z_SharedBase.__init__Nc C s t dƒ‚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 Útimeoutr r r Úacquire© s z_SharedBase.acquirec C s t dƒ‚dS )zX
Release the lock.
If the file is not locked, raise NotLocked.
zimplement in subclassN)r )r r r r Úrelease¹ s z_SharedBase.releasec C s | j ƒ | S )z*
Context manager support.
)r )r r r r Ú __enter__Á s z_SharedBase.__enter__c G s | j ƒ dS )z*
Context manager support.
N)r )r Z_excr r r Ú__exit__È s z_SharedBase.__exit__c C s d| j j| jf S )Nz<%s: %r>)Ú __class__r r )r r r r Ú__repr__Î s z_SharedBase.__repr__)N) r r r r r r r r! r# r r r r r ¥ s
r c sB e Zd ZdZd‡ fdd„ Zdd„ Zdd „ Zd
d„ Zdd
„ Z‡ Z S )r z.Base class for platform-specific lock classes.TNc s¨ t t| ƒj|ƒ tjj|ƒd | _tjƒ | _ tj
ƒ | _|rbtj
ƒ }t|dt|ƒƒ}d|d@ | _nd| _tjj| jƒ}tjj|d| j | j| jt| jƒf ƒ| _|| _dS )zi
>>> lock = LockBase('somefile')
>>> lock = LockBase('somefile', threaded=False)
z.lockÚidentz-%xl ÿÿ Ú z %s%s.%s%sN)Úsuperr r Úosr ÚabspathZ lock_fileÚsocketZgethostnameZhostnameÚgetpidÚpidÚ threadingr ÚgetattrÚhashZtnameÚdirnameÚjoinÚunique_namer )r r Úthreadedr Útr$ r/ )r" r r r Ô s
zLockBase.__init__c C s t dƒ‚dS )z9
Tell whether or not the file is locked.
zimplement in subclassN)r )r r r r Ú is_lockedõ s zLockBase.is_lockedc C s t dƒ‚dS )zA
Return True if this object is locking the file.
zimplement in subclassN)r )r r r r Úi_am_lockingû s zLockBase.i_am_lockingc C s t dƒ‚dS )zN
Remove a lock. Useful if a locking thread failed to unlock.
zimplement in subclassN)r )r r r r Ú
break_lock s zLockBase.break_lockc C s d| j j| j| jf S )Nz<%s: %r -- %r>)r" r r1 r )r r r r r# s zLockBase.__repr__)TN)
r r r r r r4 r5 r6 r# Ú
__classcell__r r )r" r r Ò s !c O sR t jd| tdd� t|d tƒs.|dd … }t|ƒdkrH| rHd|d<