dragon.mpbridge.synchronize.DragonBarrier

class DragonBarrier

Bases: Barrier

A barrier co-located on the same node by default as the creating process

__init__(parties: int , action: callable = None, timeout: float = 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

Methods

__init__(parties[, action, timeout, ctx])

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

abort()

The barrier is broken.

destroy()

Destroys the underlying Dragon resources so the space can be re-used.

reset()

Barrier is set to empty state.

serialize()

Return a serialized, base64 encoded, string that may be used by C++ code to attach to this barrier.

wait([timeout])

When all the processes party to the barrier have called wait, they are all released simultaneously.

Attributes

broken

n_waiting

parties

__init__(parties: int , action: callable = None, timeout: float = 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)

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

abort() None

The barrier is broken. Any waiters that are in wait state will receive BrokenBarrierError. :rtype: None

property broken
destroy() None

Destroys the underlying Dragon resources so the space can be re-used.

Destroys underlying Dragon resource. Only do this when you know all references to the object have been deleted.

Returns:

None

Return type:

NoneType

property n_waiting
property parties
reset() None

Barrier is set to empty state. Any waiters receive BrokenBarrierError. :rtype: None

serialize()

Return a serialized, base64 encoded, string that may be used by C++ code to attach to this barrier. Any process attaching to this barrier does not participate in the ref counting of the barrier. In other words, the lifetime of the barrier is managed by the Python process that creates it or other Python processes that have handles to it. C++ code that wishes to use it can, but the Python process must live/ wait to exit until the C++ code is done with it.

Returns:

A serialized, base64 encoded string that can be used

to attach to the barrier by the C++ Barrier implementation. :rtype: str