Repository URL to install this package:
Version:
3.3.42 ▾
|
ó ëEYc @ s` d d l Z d d l Z e j e Z d e f d YZ e Z d e f d YZ d S( iÿÿÿÿNt NeedRegenerationExceptionc B s e Z d Z RS( s An exception that when raised in the 'with' block, forces the 'has_value' flag to False and incurs a regeneration of the value. ( t __name__t __module__t __doc__( ( ( sA /home/tvault/.virtenv/lib/python2.7/site-packages/dogpile/lock.pyR s t Lockc B sP e Z d Z d d Z d Z d Z d Z d Z d Z d Z RS( sé Dogpile lock class. Provides an interface around an arbitrary mutex that allows one thread/process to be elected as the creator of a new value, while other threads/processes continue to return the previous version of that value. :param mutex: A mutex object that provides ``acquire()`` and ``release()`` methods. :param creator: Callable which returns a tuple of the form (new_value, creation_time). "new_value" should be a newly generated value representing completed state. "creation_time" should be a floating point time value which is relative to Python's ``time.time()`` call, representing the time at which the value was created. This time value should be associated with the created value. :param value_and_created_fn: Callable which returns a tuple of the form (existing_value, creation_time). This basically should return what the last local call to the ``creator()`` callable has returned, i.e. the value and the creation time, which would be assumed here to be from a cache. If the value is not available, the :class:`.NeedRegenerationException` exception should be thrown. :param expiretime: Expiration time in seconds. Set to ``None`` for never expires. This timestamp is compared to the creation_time result and ``time.time()`` to determine if the value returned by value_and_created_fn is "expired". :param async_creator: A callable. If specified, this callable will be passed the mutex as an argument and is responsible for releasing the mutex after it finishes some asynchronous value creation. The intent is for this to be used to defer invocation of the creator callable until some later time. c C s1 | | _ | | _ | | _ | | _ | | _ d S( N( t mutext creatort value_and_created_fnt expiretimet async_creator( t selfR R R R R ( ( sA /home/tvault/.virtenv/lib/python2.7/site-packages/dogpile/lock.pyt __init__6 s c C s6 | j | p5 | j d k o5 t j | | j k S( sP Return true if the expiration time is reached, or no value is available.N( t _has_valueR t Nonet time( R t createdtime( ( sA /home/tvault/.virtenv/lib/python2.7/site-packages/dogpile/lock.pyt _is_expiredD s c C s | d k S( sI Return true if the creation function has proceeded at least once.i ( ( R R ( ( sA /home/tvault/.virtenv/lib/python2.7/site-packages/dogpile/lock.pyR N s c C sÈ | j } y | } | \ } } Wn* t k rN t j d t } d } n X| j | } | t k rz | \ } } | S| t k rÀ y | \ } } | SWqÄ t k r¼ t d qÄ Xn | Sd S( NR iÿÿÿÿsH Generation function should have just been called by a concurrent thread.( R R t logt debugt NOT_REGENERATEDt _enter_createt Exception( R t value_fnt valueR t generated( ( sA /home/tvault/.virtenv/lib/python2.7/site-packages/dogpile/lock.pyt _enterS s&