dragon.mpbridge.sharedctypes

Dragon’s replacement for Multiprocessing’s shared ctypes objects: Value and Array.

Functions

Array(typecode_or_type, size_or_initializer, ...)

RawArray(typecode_or_type, size_or_initializer)

RawValue(typecode_or_type, *args[, ...])

Value(typecode_or_type, *args[, lock, ctx, ...])

dragon_copy(obj)

make a copy of a shared object

dragon_synchronized(obj[, lock, ctx])

Synchronize an object by wrapping it.

Classes

DragonArray

Array Class replacement

DragonRawArray

RawArray Class replacement for Array multiprocessing test cases

DragonRawValue

RawValue Class replacement for Value multiprocessing test cases

DragonValue

Value Class replacement

dragon_copy(obj: object) object

make a copy of a shared object

Parameters:

obj (obj) – original object

Returns:

copy of object

Return type:

obj

dragon_synchronized(obj: object, lock=None, ctx=None) object

Synchronize an object by wrapping it.

Parameters:
  • obj (object) – the object to synchronize

  • lock (multiprocessing.synchronize.Lock, optional) – multiprocessing lock for the synchronized object, defaults to None

  • ctx (multiprocessing.context.Context, optional) – multiprocessing context to use, defaults to None

Returns:

A synchronized version of the object

Return type:

object

RawValue(typecode_or_type, *args, original=None, use_base_impl=True)
RawArray(typecode_or_type, size_or_initializer, original=None, use_base_impl=True)
Value(typecode_or_type, *args, lock=True, ctx=None, original=None, use_base_impl=False)
Array(typecode_or_type, size_or_initializer, *args, lock=True, ctx=None, original=None, use_base_impl=False)
class DragonRawValue

Bases: Value

RawValue Class replacement for Value multiprocessing test cases

__init__(typecode_or_type, value: int = 0, *, ctx: None = None, raw: bool = True)

Initialize the mpbridge RawValue object. :param typecode_or_type: the typecode or type is returned from the dictionary, typecode_to_type :type typecode_or_type: str or ctypes, required :param value: the value for the object :type value: int, optional :param raw: bool, optional :type raw: sets whether lock is used or not

class DragonValue

Bases: Value

Value Class replacement

__init__(typecode_or_type, value: int = 0, *, ctx: None = None, lock: Lock = True)

Initialize the mpbridge value object. :param typecode_or_type: the typecode or type is returned from the dictionary, typecode_to_type :type typecode_or_type: str or ctypes, required :param value: the value for the object :type value: int, optional :param m_uid: memory pool to create the channel in and message to write value and typecode_or_type in managed memory, defaults to _DEF_MUID :type m_uid: int, optional :param lock: dragon.native.lock.Lock, optional :type lock: creates lock for synchronization for value

acquire()
release()
class DragonRawArray

Bases: Array

RawArray Class replacement for Array multiprocessing test cases

__init__(typecode_or_type, size_or_initializer, ctx: None = None, raw: bool = True)

Initialize the mpbridge RawArray object. :param typecode_or_type: the typecode or type is returned from the dictionary, typecode_to_type :type typecode_or_type: str or ctypes, required :param size_or_initializer: the array for the object :type size_or_initializer: range, int, list, required :param raw: bool, optional :type raw: sets whether lock is used or not

class DragonArray

Bases: Array

Array Class replacement

__init__(typecode_or_type, size_or_initializer, lock: Lock, ctx: None = None)

Initialize the mpbridge array object.

Parameters:
  • typecode_or_type (str or ctypes, required) – the typecode or type is returned from the dictionary, typecode_to_type

  • size_or_initializer (range, int, list, required) – the array for the object

  • lock (creates lock for synchronization for array) – dragon.native.lock.Lock, optional