Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
ó
¼EYc	@sPddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
mZddl
mZddlZddlmZmZejeƒZejddedd	d
dƒejddejjd
ƒddd
dƒgZd„ZejZeeƒd„Zd„Z e
j!Z!e
j"Z"de#fd„ƒYZ$e$ƒZ%dd„Z'ddd„Z(dddd„Z)dd„Z*ej+dede,ddd„ƒZ-dedddd„Z.d„Z/d„Z0d„Z1d„Z2edkrLe3ed ƒƒ‚ndS(!iÿÿÿÿN(tcfg(t
reflection(t	timeutils(t_t_LItdisable_process_lockingtdefaultthelps(Enables or disables inter-process locks.tdeprecated_grouptDEFAULTt	lock_pathtOSLO_LOCK_PATHsúDirectory to use for lock files.  For security, the specified directory should only be writable by the user running the processes that need locking. Defaults to environment variable OSLO_LOCK_PATH. If external locks are used, a lock path must be set.cCs|jtddƒdS(Ntgrouptoslo_concurrency(t
register_optst_opts(tconf((sO/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/lockutils.pyt_register_opts6scCstjtd|ƒdS(sgSet value for lock_path.

    This can be used by tests to set lock_path to a temporary directory.
    R
N(Rtset_defaultsR(R
((sO/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/lockutils.pyR>scCst|ƒ|jjS(s¥Return the path used for external file-based locks.

    :param conf: Configuration object
    :type conf: oslo_config.cfg.ConfigOpts

    .. versionadded:: 1.8
    (RR
R
(R((sO/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/lockutils.pyt
get_lock_pathFs
t
SemaphorescBs)eZdZd„Zd„Zd„ZRS(sA garbage collected container of semaphores.

    This collection internally uses a weak value dictionary so that when a
    semaphore is no longer in use (by any threads) it will automatically be
    removed from this container by the garbage collector.

    .. versionadded:: 0.3
    cCs"tjƒ|_tjƒ|_dS(N(tweakreftWeakValueDictionaryt_semaphorest	threadingtLockt_lock(tself((sO/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/lockutils.pyt__init__dsc	CsQ|jBy|j|SWn+tk
rFtjƒ}||j|<|SXWdQXdS(sFGets (or creates) a semaphore with a given name.

        :param name: The semaphore name to get/create (used to associate
                     previously created names with the same semaphore).

        Returns an newly constructed semaphore (or an existing one if it was
        already created for the given name).
        N(RRtKeyErrorRt	Semaphore(Rtnametsem((sO/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/lockutils.pytgeths	


cCs
t|jƒS(s6Returns how many semaphores exist at the current time.(tlenR(R((sO/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/lockutils.pyt__len__ys(t__name__t
__module__t__doc__RR!R#(((sO/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/lockutils.pyRZs		cCs‰|jtjdƒ}|rL|jdƒr0dnd}d|||f}n|p[tjj}|svtjdƒ‚ntj	j
||ƒS(NRt-ts%s%s%sR
(treplacetostseptendswithtCONFR
R
RtRequiredOptErrortpathtjoin(Rtlock_file_prefixR
R+tlocal_lock_path((sO/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/lockutils.pyt_get_lock_pathscCst|||ƒ}t|ƒS(N(R3tInterProcessLock(RR1R
tlock_file_path((sO/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/lockutils.pyt
external_lock‘sc	Csqt|d|ƒYt|||ƒ}ytj|ƒWn.tk
rftjtdƒi|d6ƒnXWdQXdS(svRemove an external lock file when it's not used anymore
    This will be helpful when we have a lot of lock files
    t
semaphoressFailed to remove file %(file)stfileN(t
internal_lockR3R*tremovetOSErrortLOGtinfoR(RR1R
R7R5((sO/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/lockutils.pytremove_external_lock_file—s
cCs"|dkrt}n|j|ƒS(N(tNoneRR!(RR7((sO/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/lockutils.pyR9¥s	g{®Gáz„?c	cs¿t|d|ƒ}|¡|r9tjdi|d6ƒnzX|r‹tjjr‹t|||ƒ}|jd|ƒz	|VWd|jƒXn|VWd|r´tjdi|d6ƒnXWdQXdS(sîContext based lock

    This function yields a `threading.Semaphore` instance (if we don't use
    eventlet.monkey_patch(), else `semaphore.Semaphore`) unless external is
    True, in which case, it'll yield an InterProcessLock instance.

    :param lock_file_prefix: The lock_file_prefix argument is used to provide
      lock files on disk with a meaningful prefix.

    :param external: The external keyword argument denotes whether this lock
      should work across multiple processes. This means that if two different
      workers both run a method decorated with @synchronized('mylock',
      external=True), only one of them will execute at a time.

    :param lock_path: The path in which to store external lock files.  For
      external locking to work properly, this must be the same for all
      references to the lock.

    :param do_log: Whether to log acquire/release messages.  This is primarily
      intended to reduce log message duplication when `lock` is used from the
      `synchronized` decorator.

    :param semaphores: Container that provides semaphores to use when locking.
        This ensures that threads inside the same application can not collide,
        due to the fact that external process locks are unaware of a processes
        active threads.

    :param delay: Delay between acquisition attempts (in seconds).

    .. versionchanged:: 0.2
       Added *do_log* optional parameter.

    .. versionchanged:: 0.3
       Added *delay* and *semaphores* optional parameters.
    R7sAcquired semaphore "%(lock)s"tlocktdelayNsReleasing semaphore "%(lock)s"(	R9R<tdebugR-R
RR6tacquiretrelease(	RR1texternalR
tdo_logR7RAtint_locktext_lock((sO/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/lockutils.pyR@«s&		cs"‡‡‡‡‡‡fd†}|S(sESynchronization decorator.

    Decorating a method like so::

        @synchronized('mylock')
        def foo(self, *args):
           ...

    ensures that only one thread will execute the foo method at a time.

    Different methods can share the same lock::

        @synchronized('mylock')
        def foo(self, *args):
           ...

        @synchronized('mylock')
        def bar(self, *args):
           ...

    This way only one of either foo or bar can be executing at a time.

    .. versionchanged:: 0.3
       Added *delay* and *semaphores* optional parameter.
    cs4tjˆƒ‡‡‡‡‡‡‡fd†ƒ}|S(Ncsôtjƒ}d}z}tˆˆˆˆdtdˆdˆƒPtjƒ}tjdiˆd6tjˆƒd6||d6ƒˆ||ŽSWdQXWdtjƒ}|dkr³d}nd	||}tjd
iˆd6tjˆƒd6|d6ƒXdS(NRFR7RAsFLock "%(name)s" acquired by "%(function)s" :: waited %(wait_secs)0.3fsRtfunctiont	wait_secssN/As%0.3fss@Lock "%(name)s" released by "%(function)s" :: held %(held_secs)st	held_secs(	RtnowR?R@tFalseR<RBRtget_callable_name(targstkwargstt1tt2tt3RK(RAREtfR1R
RR7(sO/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/lockutils.pytinners&	
		
(tsixtwraps(RTRU(RARER1R
RR7(RTsO/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/lockutils.pytwraps0((RR1RER
R7RARX((RARER1R
RR7sO/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/lockutils.pytsynchronizedäscCstjtd|ƒS(súPartial object generator for the synchronization decorator.

    Redefine @synchronized in each project like so::

        (in nova/utils.py)
        from oslo_concurrency import lockutils

        synchronized = lockutils.synchronized_with_prefix('nova-')


        (in nova/foo.py)
        from nova import utils

        @utils.synchronized('mylock')
        def bar(self, *args):
           ...

    The lock_file_prefix argument is used to provide lock files on disk with a
    meaningful prefix.
    R1(t	functoolstpartialRY(R1((sO/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/lockutils.pytsynchronized_with_prefix scCstjtd|ƒS(s¹Partial object generator for the remove lock file function.

    Redefine remove_external_lock_file_with_prefix in each project like so::

        (in nova/utils.py)
        from oslo_concurrency import lockutils

        synchronized = lockutils.synchronized_with_prefix('nova-')
        synchronized_remove = lockutils.remove_external_lock_file_with_prefix(
            'nova-')

        (in nova/foo.py)
        from nova import utils

        @utils.synchronized('mylock')
        def bar(self, *args):
           ...

        <eventually call synchronized_remove('mylock') to cleanup>

    The lock_file_prefix argument is used to provide lock files on disk with a
    meaningful prefix.
    R1(RZR[R>(R1((sO/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/lockutils.pyt%remove_external_lock_file_with_prefix9scCsKtjƒ}|tjd<ztj|dƒ}Wdtj|dtƒX|S(s²Create a dir for locks and pass it to command from arguments

    This is exposed as a console script entry point named
    lockutils-wrapper

    If you run this:
        lockutils-wrapper python setup.py testr <etc>

    a temporary directory will be created for all your locks and passed to all
    your tests in an environment variable. The temporary dir will be deleted
    afterwards and the return value will be preserved.
    RiNt
ignore_errors(	ttempfiletmkdtempR*tenviront
subprocesstcalltshutiltrmtreetTrue(targvtlock_dirtret_val((sO/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/lockutils.pyt
_lock_wrapperUs
cCstjttjƒƒdS(N(tsystexitRjRg(((sO/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/lockutils.pytmainlst__main__slCalling lockutils directly is no longer supported.  Please use the lockutils-wrapper console script instead.(4t
contextlibRZtloggingR*RdRbRkR_RRt	fastenerstoslo_configRt
oslo_utilsRRRVtoslo_concurrency._i18nRRt	getLoggerR$R<tBoolOptRMtStrOptRaR!RRR-RRR4tReaderWriterLocktobjectRRR?R3R6R>R9tcontextmanagerRfR@RYR\R]RjRmtNotImplementedError(((sO/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/lockutils.pyt<module>s`		
				$	
	7	;