OwlCyberSecurity - MANAGER
Edit File: memcachelock.pyc
� �t�ac @ s~ d d l m Z d d l m Z m Z m Z m Z d d l m Z d d l Z d e f d � � YZ d e f d � � YZ d S( i����( t Memcacher( t inlineCallbackst Deferredt returnValuet succeed( t reactorNt MemcacheLockc B sM e Z d d d d � Z d � Z e d � � Z d � Z d � Z d � Z RS( g @g�������?i c C sG t t | � j | � | | _ | | _ | | _ | | _ t | _ d S( s @param namespace: a unique namespace for this lock's tokens @type namespace: C{str} @param locktoken: the name of the locktoken @type locktoken: C{str} @param timeout: the maximum time in seconds that the lock should block @type timeout: C{float} @param retry_interval: the interval to retry acquiring the lock @type retry_interval: C{float} @param expiryTime: the time in seconds for the lock to expire. Zero: no expiration. @type expiryTime: C{float} N( t superR t __init__t _locktokent _timeoutt _retry_intervalt _expire_timet Falset _hasLock( t selft namespacet locktokent timeoutt retry_intervalt expire_time( ( s- /opt/cpanel-ccs/twistedcaldav/memcachelock.pyR s c C s: t t | � j � } t | t j � r6 t d � � n | S( Ns5 No implementation of shared locking without memcached( R R t _getMemcacheProtocolt isinstanceR t nullCachert AssertionError( R t result( ( s- /opt/cpanel-ccs/twistedcaldav/memcachelock.pyR 0 s c # s- | j s t d � � t j � | j } t } x� t r| j | j d d | j �V} | r� t | _ | r� | j j d d | j �n Pn | j r� t j � | k r� t } | j j d d | j �t � � � f d � } t j | j | � � Vq2 | j j d d | j �t � � q2 Wt t � d S( Ns Lock already acquired.t 1t expireTimes Got lock after waiting on {t}t ts Waiting for lock on {t}c s � j t � d S( N( t callbackt True( ( t pause( s- /opt/cpanel-ccs/twistedcaldav/memcachelock.pyt _timedDeferredN s s# Timed out lock after waiting on {t}( R R t timeR R R t addR R t logt debugR R t callLaterR t MemcacheLockTimeoutErrorR ( R t timeout_att waitingR R ( ( R s- /opt/cpanel-ccs/twistedcaldav/memcachelock.pyt acquire9 s( c sG � j s t d � � � f d � } � j � j � } | j | � | S( Ns Lock not acquired.c s t � _ | S( N( R R ( R ( R ( s- /opt/cpanel-ccs/twistedcaldav/memcachelock.pyt _done\ s ( R R t deleteR t addCallback( R R* t d( ( R s- /opt/cpanel-ccs/twistedcaldav/memcachelock.pyt releaseX s c C s! | j r | j � St t � Sd S( N( R R. R R ( R ( ( s- /opt/cpanel-ccs/twistedcaldav/memcachelock.pyt cleand s c C s, d � } | j | j � } | j | � | S( s; Test if the lock is currently being held. c S s | d k S( N( t None( t value( ( s- /opt/cpanel-ccs/twistedcaldav/memcachelock.pyt _gotitp s ( t getR R, ( R R2 R- ( ( s- /opt/cpanel-ccs/twistedcaldav/memcachelock.pyt lockedk s ( t __name__t __module__R R R R) R. R/ R4 ( ( ( s- /opt/cpanel-ccs/twistedcaldav/memcachelock.pyR s R&