ok
Direktori : /proc/self/root/proc/self/root/usr/lib/python2.7/site-packages/rhn/ |
Current File : //proc/self/root/proc/self/root/usr/lib/python2.7/site-packages/rhn/rhnLockfile.pyc |
� ��Qc @ s� d d l Z d d l Z d d l Z d d l m Z m Z d d l Z d e f d � � YZ d d d � � YZ d � Z e d k r� e j e � p� d � n d S( i����N( t EWOULDBLOCKt EEXISTt LockfileLockedExceptionc B s e Z d Z RS( s$ thrown ONLY when pid file is locked.( t __name__t __module__t __doc__( ( ( s3 /usr/lib/python2.7/site-packages/rhn/rhnLockfile.pyR s t Lockfilec B s, e Z d Z d d � Z d � Z d � Z RS( 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. c C s� t j j t j j t j j | � � � | _ | | _ | j sQ t j � | _ n t j j | j � } t j j | � s� y t j | � Wq� t k r� } t | d � r� | j t k r� q� � q� Xn t j | j t j t j Bt j B� | _ | j � d S( sl create (if need be), and acquire lock on lockfile lockfile example: '/var/run/up2date.pid' t errnoN( t ost patht abspatht expandusert expandvarst lockfilet pidt getpidt dirnamet existst makedirst OSErrort hasattrR R t opent O_RDWRt O_CREATt O_SYNCt ft acquire( t selfR R R t e( ( s3 /usr/lib/python2.7/site-packages/rhn/rhnLockfile.pyt __init__# s )c C s� y! t j | j t j t j B� WnK t k rn } | j t k rh t d | j � d t j � d � qo � n Xt j | j t j d � t j | j d � t j | j t | j � d � d S( s5 acquire the lock; else raise LockfileLockedException.s cannot acquire lock on %s.i i i s N( t fcntlt flockR t LOCK_EXt LOCK_NBt IOErrorR R R R t Nonet syst exc_infot F_SETFDR t ftruncatet writet strR ( R R ( ( s3 /usr/lib/python2.7/site-packages/rhn/rhnLockfile.pyR C s !#c C s: t j | j � t j | j t j � t j | j � d S( N( R t unlinkR R R R t LOCK_UNt close( R ( ( s3 /usr/lib/python2.7/site-packages/rhn/rhnLockfile.pyt releaseT s N( R R R R# R R R- ( ( ( s3 /usr/lib/python2.7/site-packages/rhn/rhnLockfile.pyR s c C s} y t d � } Wn4 t k rF } t j j d | � t j d � n3 Xd GHd GHd d l } | j d � | j � d GHd S( s test codes ./test.pids %s i����s lock acquired s ...sleeping for 10 secondsNi s lock released ( R R R$ t stderrR( t exitt timet sleepR- ( t LR R0 ( ( s3 /usr/lib/python2.7/site-packages/rhn/rhnLockfile.pyt main[ s t __main__i ( ( R R$ R R R R t ExceptionR R R3 R R/ ( ( ( s3 /usr/lib/python2.7/site-packages/rhn/rhnLockfile.pyt <module> s A