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Êã@stdZddlmZddlZddlZddlZddlmZmZm Z m Z m Z m Z Gdd„deƒZ dd „Zd d „Zd d „ZdS)z8 Lockfile behaviour implemented via Unix PID files. é)Úabsolute_importNé)ÚLockBaseÚ AlreadyLockedÚ LockFailedÚ NotLockedÚ NotMyLockÚ LockTimeoutc@sLeZdZdZddd„Zdd„Zdd „Zd d „Zdd d „Zdd„Z dd„Z dS)Ú PIDLockFileaA Lockfile implemented as a Unix PID file. The lock file is a normal file named by the attribute `path`. A lock's PID file contains a single line of text, containing the process ID (PID) of the process that acquired the lock. >>> lock = PIDLockFile('somefile') >>> lock = PIDLockFile('somefile') FNcCstj||d|ƒ|j|_dS)NF)rÚ__init__ÚpathZ unique_name)Úselfr ZthreadedÚtimeout©rú!/usr/lib/python3.6/pidlockfile.pyr $szPIDLockFile.__init__cCs t|jƒS)z- Get the PID from the lock file. )Úread_pid_from_pidfiler )r rrrÚread_pid*szPIDLockFile.read_pidcCstjj|jƒS)zv Test if the lock is currently held. The lock is held if the PID file for this lock exists. )Úosr Úexists)r rrrÚ is_locked/szPIDLockFile.is_lockedcCs|jƒotjƒ|jƒkS)z¡ Test if the lock is held by the current process. Returns ``True`` if the current process ID matches the number stored in the PID file. )rrÚgetpidr)r rrrÚ i_am_locking7szPIDLockFile.i_am_lockingcCsâ|dk r |n|j}tjƒ}|dk r2|dkr2||7}xªyt|jƒWn’tk rÔ}zv|jtjkr¶tjƒ|krš|dk rŒ|dkrŒtd|jƒ‚ntd|jƒ‚tj |dk r®|dp°dƒnt d|jƒ‚WYdd}~Xq4XdSq4WdS)z† Acquire the lock. Creates the PID file for this lock, or raises an error if the lock could not be acquired. Nrz&Timeout waiting to acquire lock for %sz%s is already lockedé gš™™™™™¹?zfailed to create %s) rÚtimeÚwrite_pid_to_pidfiler ÚOSErrorÚerrnoZEEXISTr rZsleepr)r rZend_timeÚexcrrrÚacquire?s$     zPIDLockFile.acquirecCs:|jƒstd|jƒ‚|jƒs,td|jƒ‚t|jƒdS)z¥ Release the lock. Removes the PID file to release the lock, or raises an error if the current process does not hold the lock. z%s is not lockedz%s is locked, but not by meN)rrr rrÚremove_existing_pidfile)r rrrÚrelease_s zPIDLockFile.releasecCst|jƒdS)z‚ Break an existing lock. Removes the PID file if it already exists, otherwise does nothing. N)rr )r rrrÚ break_locklszPIDLockFile.break_lock)FN)N) Ú__name__Ú __module__Ú __qualname__Ú__doc__r rrrrr r!rrrrr s    r cCsbd}yt|dƒ}Wntk r&Yn8X|jƒjƒ}y t|ƒ}Wntk rTYnX|jƒ|S)zï Read the PID recorded in the named PID file. Read and return the numeric PID recorded as text in the named PID file. If the PID file cannot be read, or if the content is not a valid PID, return ``None``. NÚr)ÚopenÚIOErrorÚreadlineÚstripÚintÚ ValueErrorÚclose)Ú pidfile_pathÚpidÚpidfileÚlinerrrrvs  rcCsRtjtjBtjB}d}tj|||ƒ}tj|dƒ}tjƒ}|jd|ƒ|jƒdS)u° Write the PID in the named PID file. Get the numeric process ID (“PIDâ€�) of the current process and write it to the named file as a line of text. i¤Úwz%s N) rÚO_CREATÚO_EXCLÚO_WRONLYr'ÚfdopenrÚwriter-)r.Z open_flagsZ open_modeZ pidfile_fdr0r/rrrr˜s rcCsFytj|ƒWn2tk r@}z|jtjkr.n‚WYdd}~XnXdS)zÏ Remove the named PID file if it exists. Removing a PID file that doesn't already exist puts us in the desired state, so we ignore the condition if the file does not exist. N)rÚremoverrÚENOENT)r.rrrrr°s  r)r%Z __future__rrrrÚrrrrrr r rrrrrrrÚ s  ]"