ezmsg.tools.shmem.shmem_mirror#

It is possible to move data from ezmsg to non-ezmsg processes using shared memory. This module contains the non-ezmsg half of that communication. The ezmsg half is found in .shmem. The same shmem_name must be passed to both the ShMemCircBuff and the EZShmMirror objects!

Classes

class EZShmMirror(shmem_name=None)[source]#

Bases: object

An object that has a local (in-client-process) representation of the shared memory from another process’ .shmem.ShMemCircBuff Unit.

There are 2 pieces of shared memory: the metadata and the data buffer. The ezmsg node is responsible for creating both pieces. Here we only connect to them. We cannot know if the shared memory exists before we try to connect to it, so we must try the connection – sometimes repeatedly while handling connection errors.

Parameters:

shmem_name (str | None)

__init__(shmem_name=None)[source]#
Parameters:

shmem_name (str | None)

disconnect()[source]#
property meta: ShmemArrMeta | None#
property buffer: ndarray[tuple[int, ...], dtype[_ScalarType_co]] | None#
property write_index: int | None#
property connected: bool#
register_change_callback(callback)[source]#
Parameters:

callback (Callable)

Return type:

None

unregister_change_callback()[source]#
Return type:

None

connect(name)[source]#
Parameters:

name (str)

Return type:

None

auto_view(n=None)[source]#
Parameters:

n (int | None)

Return type:

Tuple[ndarray[tuple[int, …], dtype[_ScalarType_co]], bool]

class EZShmMirror(shmem_name=None)[source]#

Bases: object

An object that has a local (in-client-process) representation of the shared memory from another process’ .shmem.ShMemCircBuff Unit.

There are 2 pieces of shared memory: the metadata and the data buffer. The ezmsg node is responsible for creating both pieces. Here we only connect to them. We cannot know if the shared memory exists before we try to connect to it, so we must try the connection – sometimes repeatedly while handling connection errors.

Parameters:

shmem_name (str | None)

__init__(shmem_name=None)[source]#
Parameters:

shmem_name (str | None)

disconnect()[source]#
property meta: ShmemArrMeta | None#
property buffer: ndarray[tuple[int, ...], dtype[_ScalarType_co]] | None#
property write_index: int | None#
property connected: bool#
register_change_callback(callback)[source]#
Parameters:

callback (Callable)

Return type:

None

unregister_change_callback()[source]#
Return type:

None

connect(name)[source]#
Parameters:

name (str)

Return type:

None

auto_view(n=None)[source]#
Parameters:

n (int | None)

Return type:

Tuple[ndarray[tuple[int, …], dtype[_ScalarType_co]], bool]