dragon.mpbridge.synchronize

Dragon’s replacements for the synchronization primitives in Multiprocessing. Except for Condition, all components are based on dragon.native component and are implemented over one or more dragon channels. Lock is patched with a dummy _SemLock class, so Condition works out of the box.

Functions

Barrier(parties[, action, timeout, ctx, ...])

BoundedSemaphore(value[, ctx, use_base_impl])

Condition(lock[, ctx, use_base_impl])

Event([ctx, use_base_impl])

Lock([ctx, use_base_impl])

RLock([ctx, use_base_impl])

Semaphore(value[, ctx, use_base_impl])

Classes

AugmentedDragonNativeLock

Augment the Dragon Native Lock so it can be used by Python Multiprocessing

BaseImplBarrier

BaseImplBoundedSemaphore

BaseImplCondition

BaseImplEvent

BaseImplLock

BaseImplRLock

BaseImplSemaphore

DragonBarrier

DragonBoundedSemaphore

DragonCondition

Dragons replacement for the Multiprocessing Condition removes all references to _semlock and the test for assert_spawning.

DragonEvent

DragonLock

DragonRLock

DragonSemaphore

class AugmentedDragonNativeLock

Augment the Dragon Native Lock so it can be used by Python Multiprocessing

__init__(*args, **kwargs)

Initialize the lock object

Parameters
  • m_uid (int, optional) – memory pool to create the channel in, defaults to _DEF_MUID

  • recursive (bool, optional) – if the Lock should be recursive, defaults to False

class DragonLock
__init__(*args, ctx, **kwargs)

Initialize the lock object

Parameters
  • m_uid (int, optional) – memory pool to create the channel in, defaults to _DEF_MUID

  • recursive (bool, optional) – if the Lock should be recursive, defaults to False

class DragonRLock
__init__(*args, ctx, **kwargs)

Initialize the lock object

Parameters
  • m_uid (int, optional) – memory pool to create the channel in, defaults to _DEF_MUID

  • recursive (bool, optional) – if the Lock should be recursive, defaults to False

class DragonCondition

Dragons replacement for the Multiprocessing Condition removes all references to _semlock and the test for assert_spawning. The _semlock interface is mapped onto Dragon’s native Lock implementation.

class DragonSemaphore
__init__(*args, ctx, **kwargs)

Create a Semaphore object that can be shared across Dragon processes.

Parameters
  • value (int, optional) – initial value for the counter, defaults to 1

  • m_uid (int, optional) – dragon managed memory pool id to use, defaults to the standard pool.

  • bounded (bool, optional) – set if the value of the Semaphore cannot exceed its initial value, defaults to False

class DragonBoundedSemaphore
__init__(*args, ctx, **kwargs)

Create a Semaphore object that can be shared across Dragon processes.

Parameters
  • value (int, optional) – initial value for the counter, defaults to 1

  • m_uid (int, optional) – dragon managed memory pool id to use, defaults to the standard pool.

  • bounded (bool, optional) – set if the value of the Semaphore cannot exceed its initial value, defaults to False

class DragonEvent
__init__(*args, ctx, **kwargs)

Initialize an event object :param m_uid: memory pool to create the channel in, defaults to _DEF_MUID :type m_uid: int, optional

class DragonBarrier
__init__(parties: int, action: Optional[callable] = None, timeout: Optional[float] = None, *, ctx=None)

Initialize a barrier object :param parties: number of parties for the barrier to act upon :type parties: int, optional, > 2 :param action: class that the barrier calls upon :type callable: optional :param timeout: timeout for barrier :type timeout: float, optional :param m_uid: memory pool to create the channel in, defaults to _DEF_MUID :type m_uid: int, optional

wait(timeout: Optional[float] = None)

When all the processes party to the barrier have called wait, they are all released simultaneously. The timeout for wait takes precedence over constructor. :param timeout: timeout for barrier :type timeout: float, optional :rtype: None

class BaseImplBarrier
__init__(*args, **kwargs)

Create a barrier, initialised to ‘parties’ threads.

‘action’ is a callable which, when supplied, will be called by one of the threads after they have all entered the barrier and just prior to releasing them all. If a ‘timeout’ is provided, it is used as the default for all subsequent ‘wait()’ calls.