tacker.common.coordination module

Coordination and locking utilities.

class tacker.common.coordination.Coordinator(agent_id=None, prefix='')

Bases: object

Tooz coordination wrapper.

Coordination member id is created from concatenated prefix and agent_id parameters.

  • agent_id (str) – Agent identifier

  • prefix (str) – Used to provide member identifier with a meaningful prefix.


Return a Tooz backend lock.


name (str) – The lock name that is used to identify it across all nodes.


Disconnect from coordination backend and stop heartbeat.

tacker.common.coordination.synchronized(lock_name, blocking=True, coordinator=<tacker.common.coordination.Coordinator object>)

Synchronization decorator.

  • lock_name (str) – Lock name.

  • blocking – If True, blocks until the lock is acquired. If False, raises exception when not acquired. Otherwise, the value is used as a timeout value and if lock is not acquired after this number of seconds exception is raised.

  • coordinator – Coordinator class to use when creating lock. Defaults to the global coordinator.


tooz.coordination.LockAcquireFailed – if lock is not acquired

Decorating a method like so:

def foo(self, *args):

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

Different methods can share the same lock:

def foo(self, *args):

def bar(self, *args):

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

Lock name can be formatted using Python format string syntax:

def foo(self, vnf):

Available field names are: decorated function parameters and f_name as a decorated function name.