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

Bases: Lock

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

Bases: AugmentedDragonNativeLock

__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

Bases: AugmentedDragonNativeLock

__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 BaseImplLock

Bases: Lock

__init__(*args, **kwargs)
class BaseImplRLock

Bases: RLock

__init__(*args, **kwargs)
class DragonCondition

Bases: Condition

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 BaseImplCondition

Bases: Condition

__init__(*args, **kwargs)
class DragonSemaphore

Bases: Semaphore

__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

Bases: Semaphore

__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 BaseImplSemaphore

Bases: Semaphore

__init__(*args, **kwargs)
class BaseImplBoundedSemaphore

Bases: BoundedSemaphore

__init__(*args, **kwargs)
class DragonEvent

Bases: Event

__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 BaseImplEvent

Bases: Event

__init__(*args, **kwargs)
class DragonBarrier

Bases: Barrier

__init__(parties: int, action: callable | None = None, timeout: float | None = None, *, ctx=None)

Initialize a barrier object :param parties: number of parties for the barrier to act upon :type parties: int, optional, > 1 :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: float | None = 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

Bases: Barrier

__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.

Lock(ctx=None, use_base_impl=False)
RLock(ctx=None, use_base_impl=False)
Condition(lock, ctx=None, use_base_impl=False)
Semaphore(value, ctx=None, use_base_impl=False)
BoundedSemaphore(value, ctx=None, use_base_impl=False)
Event(ctx=None, use_base_impl=False)
Barrier(parties, action=None, timeout=None, ctx=None, use_base_impl=False)