Module Import alias Import alias Import alias Import alias Import alias Import alias Import alias Import alias Import alias Import alias Import alias ImportFrom alias ImportFrom alias ImportFrom alias Import alias ImportFrom alias alias Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore ListLoad Call AttributeLoad NameLoad attr Str keyword NameLoad keyword Str keyword Str Call AttributeLoad NameLoad attr Str keyword Call AttributeLoad AttributeLoad NameLoad attr attr Str keyword Str keyword Str FunctionDef arguments args NameParam defaults body Expr Call AttributeLoad NameLoad attr NameLoad keyword Str decorator_list Assign NameStore AttributeLoad NameLoad attr Expr Call NameLoad NameLoad FunctionDef arguments args NameParam defaults body Expr Str Expr Call AttributeLoad NameLoad attr NameLoad keyword NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Expr Call NameLoad NameLoad Return AttributeLoad AttributeLoad NameLoad attr attr decorator_list Assign NameStore AttributeLoad NameLoad attr Assign NameStore AttributeLoad NameLoad attr Expr Str ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam defaults body Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str With AttributeLoad NameLoad attr body TryExcept body Return SubscriptLoad AttributeLoad NameLoad attr Index NameLoad handlers ExceptHandler type NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Assign SubscriptStore AttributeLoad NameLoad attr Index NameLoad NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call NameLoad AttributeLoad NameLoad attr decorator_list decorator_list Assign NameStore Call NameLoad FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Str If NameLoad body Assign NameStore IfExp Call AttributeLoad NameLoad attr Str Str Str Assign NameStore BinOpMod Str TupleLoad NameLoad NameLoad NameLoad Assign NameStore BoolOpOr NameLoad AttributeLoad AttributeLoad NameLoad attr attr If UnaryOpNot NameLoad body Raise Call AttributeLoad NameLoad attr Str Return Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad NameLoad body Assign NameStore Call NameLoad NameLoad NameLoad NameLoad Return Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad NameLoad NameLoad body Expr Str With Call NameLoad NameLoad keyword NameLoad body Assign NameStore Call NameLoad NameLoad NameLoad NameLoad TryExcept body Expr Call AttributeLoad NameLoad attr NameLoad handlers ExceptHandler type NameLoad body Expr Call AttributeLoad NameLoad attr Call NameLoad Str Dict Str NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body If CompareIs NameLoad NameLoad body Assign NameStore NameLoad Return Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam NameParam defaults NameLoad NameLoad NameLoad NameLoad NameLoad Num body Expr Str Assign NameStore Call NameLoad NameLoad keyword NameLoad With NameLoad body If NameLoad body Expr Call AttributeLoad NameLoad attr Str Dict Str NameLoad TryFinally body If BoolOpAnd NameLoad UnaryOpNot AttributeLoad AttributeLoad NameLoad attr attr body Assign NameStore Call NameLoad NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr keyword NameLoad TryFinally body Expr Yield NameLoad finalbody Expr Call AttributeLoad NameLoad attr orelse Expr Yield NameLoad finalbody If NameLoad body Expr Call AttributeLoad NameLoad attr Str Dict Str NameLoad decorator_list AttributeLoad NameLoad attr FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam defaults NameLoad NameLoad NameLoad NameLoad Num body Expr Str FunctionDef arguments args NameParam defaults body FunctionDef arguments args defaults vararg kwarg body Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore NameLoad TryFinally body With Call NameLoad NameLoad NameLoad NameLoad NameLoad keyword NameLoad keyword NameLoad keyword NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Str Dict Str Str Str NameLoad Call AttributeLoad NameLoad attr NameLoad BinOpSub NameLoad NameLoad Return Call NameLoad NameLoad NameLoad finalbody Assign NameStore Call AttributeLoad NameLoad attr If CompareIs NameLoad NameLoad body Assign NameStore Str orelse Assign NameStore BinOpMod Str BinOpSub NameLoad NameLoad Expr Call AttributeLoad NameLoad attr Str Dict Str Str Str NameLoad Call AttributeLoad NameLoad attr NameLoad NameLoad decorator_list Call AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call AttributeLoad NameLoad attr NameLoad keyword NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call AttributeLoad NameLoad attr NameLoad keyword NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr Assign SubscriptStore AttributeLoad NameLoad attr Index Str NameLoad TryFinally body Assign NameStore Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Slice Num finalbody Expr Call AttributeLoad NameLoad attr NameLoad keyword NameLoad Return NameLoad decorator_list FunctionDef arguments args defaults body Expr Call AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr decorator_list If CompareEq NameLoad Str body Raise Call NameLoad Call NameLoad Str
N/A N/A contextlib N/A functools N/A logging N/A os N/A shutil N/A subprocess N/A sys N/A tempfile N/A threading N/A weakref N/A fasteners oslo_config cfg oslo_utils reflection oslo_utils timeutils N/A six oslo_concurrency._i18n _ _LI N/A LOG N/A N/A logging getLogger __name__ N/A _opts N/A N/A N/A cfg BoolOpt disable_process_locking default False help Enables or disables inter-process locks. deprecated_group DEFAULT N/A N/A cfg StrOpt lock_path default N/A N/A N/A os environ get OSLO_LOCK_PATH help 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. deprecated_group DEFAULT _register_opts N/A N/A conf N/A N/A N/A N/A N/A conf register_opts _opts group oslo_concurrency N/A N/A CONF N/A cfg CONF N/A N/A _register_opts CONF set_defaults N/A N/A lock_path N/A N/A N/A Set value for lock_path.

    This can be used by tests to set lock_path to a temporary directory.
     N/A N/A N/A cfg set_defaults _opts lock_path lock_path N/A get_lock_path N/A N/A conf N/A N/A N/A Return the path used for external file-based locks.

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

    .. versionadded:: 1.8
     N/A N/A _register_opts conf N/A N/A N/A conf oslo_concurrency lock_path N/A N/A InterProcessLock N/A fasteners InterProcessLock N/A ReaderWriterLock N/A fasteners ReaderWriterLock N/A A reader/writer lock.

.. versionadded:: 0.4
 Semaphores N/A object N/A N/A A 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
     __init__ N/A N/A self N/A N/A N/A N/A self _semaphores N/A N/A weakref WeakValueDictionary N/A N/A self _lock N/A N/A threading Lock N/A get N/A N/A self name N/A N/A N/A Gets (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/A N/A self _lock N/A N/A N/A N/A N/A N/A self _semaphores N/A name N/A N/A N/A KeyError N/A N/A sem N/A N/A threading Semaphore N/A N/A N/A self _semaphores N/A name sem N/A sem N/A __len__ N/A N/A self N/A N/A N/A Returns how many semaphores exist at the current time. N/A N/A len N/A self _semaphores N/A N/A N/A _semaphores N/A Semaphores _get_lock_path N/A N/A name lock_file_prefix lock_path N/A None N/A N/A name N/A N/A name replace N/A os sep _ N/A lock_file_prefix N/A N/A sep N/A N/A N/A lock_file_prefix endswith - - N/A name N/A %s%s%s N/A lock_file_prefix sep name N/A local_lock_path N/A lock_path N/A N/A CONF oslo_concurrency lock_path N/A N/A local_lock_path N/A N/A N/A N/A cfg RequiredOptError lock_path N/A N/A N/A N/A os path join local_lock_path name N/A external_lock N/A N/A name lock_file_prefix lock_path N/A None None N/A N/A lock_file_path N/A _get_lock_path name lock_file_prefix lock_path N/A N/A InterProcessLock lock_file_path N/A remove_external_lock_file N/A N/A name lock_file_prefix lock_path semaphores N/A None None None N/A N/A Remove an external lock file when it's not used anymore
    This will be helpful when we have a lot of lock files
     N/A N/A internal_lock name semaphores semaphores N/A N/A lock_file_path N/A _get_lock_path name lock_file_prefix lock_path N/A N/A N/A N/A N/A os remove lock_file_path N/A N/A N/A OSError N/A N/A N/A N/A LOG info N/A _LI Failed to remove file %(file)s N/A file lock_file_path N/A internal_lock N/A N/A name semaphores N/A None N/A N/A N/A semaphores None N/A N/A semaphores _semaphores N/A N/A N/A semaphores get name N/A lock N/A N/A name lock_file_prefix external lock_path do_log semaphores delay N/A None False None True None 0.01 N/A N/A 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.
     N/A int_lock N/A internal_lock name semaphores semaphores N/A int_lock N/A N/A do_log N/A N/A N/A N/A LOG debug Acquired semaphore "%(lock)s" N/A lock name N/A N/A N/A N/A external N/A N/A N/A CONF oslo_concurrency disable_process_locking N/A N/A ext_lock N/A external_lock name lock_file_prefix lock_path N/A N/A N/A ext_lock acquire delay delay N/A N/A N/A N/A ext_lock N/A N/A N/A N/A ext_lock release N/A N/A N/A int_lock N/A N/A do_log N/A N/A N/A N/A LOG debug Releasing semaphore "%(lock)s" N/A lock name N/A N/A contextlib contextmanager synchronized N/A N/A name lock_file_prefix external lock_path semaphores delay N/A None False None None 0.01 N/A N/A Synchronization 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.
     wrap N/A N/A f N/A N/A inner N/A N/A N/A args kwargs N/A N/A t1 N/A N/A timeutils now N/A t2 None N/A N/A N/A N/A lock name lock_file_prefix external lock_path do_log False semaphores semaphores delay delay N/A N/A t2 N/A N/A timeutils now N/A N/A N/A LOG debug Lock "%(name)s" acquired by "%(function)s" :: waited %(wait_secs)0.3fs N/A name function wait_secs name N/A N/A reflection get_callable_name f N/A t2 t1 N/A N/A f args kwargs N/A N/A t3 N/A N/A timeutils now N/A N/A t2 None N/A N/A held_secs N/A N/A N/A held_secs N/A %0.3fs N/A t3 t2 N/A N/A N/A LOG debug Lock "%(name)s" released by "%(function)s" :: held %(held_secs)s N/A name function held_secs name N/A N/A reflection get_callable_name f held_secs N/A N/A N/A six wraps f N/A inner N/A N/A wrap N/A synchronized_with_prefix N/A N/A lock_file_prefix N/A N/A N/A Partial object generator for the synchronization decorator.

    Redefine @synchronized in each project like so::

        (in nova/utils.py)
        from nova.openstack.common 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.
     N/A N/A N/A functools partial synchronized lock_file_prefix lock_file_prefix N/A remove_external_lock_file_with_prefix N/A N/A lock_file_prefix N/A N/A N/A 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 nova.openstack.common 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.
     N/A N/A N/A functools partial remove_external_lock_file lock_file_prefix lock_file_prefix N/A _lock_wrapper N/A N/A argv N/A N/A N/A 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.
     N/A lock_dir N/A N/A tempfile mkdtemp N/A N/A N/A os environ N/A OSLO_LOCK_PATH lock_dir N/A N/A N/A ret_val N/A N/A subprocess call N/A argv N/A 1 N/A N/A N/A N/A shutil rmtree lock_dir ignore_errors True N/A ret_val N/A main N/A N/A N/A N/A N/A N/A N/A sys exit N/A _lock_wrapper N/A sys argv N/A N/A N/A __name__ __main__ N/A N/A N/A NotImplementedError N/A _ Calling lockutils directly is no longer supported.  Please use the lockutils-wrapper console script instead.