node#

Messenger objects for communication intra, interprocess and intercomputer

class perceptivo.networking.node.Node(socket: perceptivo.types.networking.Socket, poll_mode: perceptivo.networking.node.Node.Poll_Mode = Poll_Mode.IOLOOP, callback: Optional[Callable] = None, to: Optional[str] = None, deque_size: int = 256)#

Bases: perceptivo.root.Perceptivo_Object

Wrapper around zmq sockets to send and receive messages

Parameters
  • socket (types.Socket) – Socket descriptor (see Socket)

  • poll_mode (Poll_Mode) – Strategy for polling messages.

    • IOLOOP - uses tornado’s IOloop and ZMQStreams to poll for messages.

      Needs to be given callback as well, which will be called with the received message as the only argument

    • DEQUE - a thread is spawned to poll the socket and add any message to deque

    • NONE - interact with the socket manually

  • callback (typing.Callable) – A callable object that will be called with a received message as its only argument if poll_mode == IOLOOP

class Poll_Mode(value)#

Bases: enum.Enum

An enumeration.

IOLOOP = 1#
DEQUE = 2#
NONE = 3#
__init__(socket: perceptivo.types.networking.Socket, poll_mode: perceptivo.networking.node.Node.Poll_Mode = Poll_Mode.IOLOOP, callback: Optional[Callable] = None, to: Optional[str] = None, deque_size: int = 256)#

Wrapper around zmq sockets to send and receive messages

Parameters
  • socket (types.Socket) – Socket descriptor (see Socket)

  • poll_mode (Poll_Mode) – Strategy for polling messages.

    • IOLOOP - uses tornado’s IOloop and ZMQStreams to poll for messages.

      Needs to be given callback as well, which will be called with the received message as the only argument

    • DEQUE - a thread is spawned to poll the socket and add any message to deque

    • NONE - interact with the socket manually

  • callback (typing.Callable) – A callable object that will be called with a received message as its only argument if poll_mode == IOLOOP

property address: str#

The full address, including protocol, ip, port, or endpoint, depending on the protocol

Returns

str

send(msg: Optional[perceptivo.networking.messages.Message] = None, to: Optional[str] = None, **kwargs)#

for now just wrapping the socket

_start_ioloop(loop: tornado.ioloop.IOLoop)#

spawn a tornado ioloop

_start_polling()#

spawn a thread to poll the socket and add incoming messages to the queue

release()#