ok

Mini Shell

Direktori : /proc/thread-self/root/usr/lib/python2.7/site-packages/rhn/
Upload File :
Current File : //proc/thread-self/root/usr/lib/python2.7/site-packages/rhn/rhnLockfile.pyc

�
��Qc@s�ddlZddlZddlZddlmZmZddlZdefd��YZdd
d��YZd�Z	e
dkr�eje	�p�d	�ndS(i����N(tEWOULDBLOCKtEEXISTtLockfileLockedExceptioncBseZdZRS(s$thrown ONLY when pid file is locked.(t__name__t
__module__t__doc__(((s3/usr/lib/python2.7/site-packages/rhn/rhnLockfile.pyRstLockfilecBs,eZdZdd�Zd�Zd�ZRS(s�class that provides simple access to a PID-style lockfile.

    methods: __init__(lockfile), acquire(), and release()
    NOTE: currently acquires upon init
    The *.pid file will be acquired, or an LockfileLockedException is raised.
    cCs�tjjtjjtjj|���|_||_|jsQtj�|_ntjj|j�}tjj	|�s�ytj
|�Wq�tk
r�}t|d�r�|j
tkr�q��q�Xntj|jtjtjBtjB�|_|j�dS(slcreate (if need be), and acquire lock on lockfile

        lockfile example: '/var/run/up2date.pid'
        terrnoN(tostpathtabspatht
expandusert
expandvarstlockfiletpidtgetpidtdirnametexiststmakedirstOSErrorthasattrRRtopentO_RDWRtO_CREATtO_SYNCtftacquire(tselfR
RRte((s3/usr/lib/python2.7/site-packages/rhn/rhnLockfile.pyt__init__#s 				
)cCs�y!tj|jtjtjB�WnKtk
rn}|jtkrhtd|j	�dtj�d�qo�nXtj|jtj
d�tj|jd�tj|jt|j�d�dS(s5acquire the lock; else raise LockfileLockedException.scannot acquire lock on %s.iiis
N(tfcntltflockRtLOCK_EXtLOCK_NBtIOErrorRRRR
tNonetsystexc_infotF_SETFDRt	ftruncatetwritetstrR(RR((s3/usr/lib/python2.7/site-packages/rhn/rhnLockfile.pyRCs!#cCs:tj|j�tj|jtj�tj|j�dS(N(RtunlinkR
RRRtLOCK_UNtclose(R((s3/usr/lib/python2.7/site-packages/rhn/rhnLockfile.pytreleaseTsN(RRRR#RRR-(((s3/usr/lib/python2.7/site-packages/rhn/rhnLockfile.pyRs 	cCs}ytd�}Wn4tk
rF}tjjd|�tjd�n3XdGHdGHddl}|jd�|j�dGHdS(	s	test codes
./test.pids%s
i����slock acquired s...sleeping for 10 secondsNi
slock released (	RRR$tstderrR(texitttimetsleepR-(tLRR0((s3/usr/lib/python2.7/site-packages/rhn/rhnLockfile.pytmain[s

t__main__i((RR$RRRRt	ExceptionRRR3RR/(((s3/usr/lib/python2.7/site-packages/rhn/rhnLockfile.pyt<module>sA	

Zerion Mini Shell 1.0