Skip to content

flowmachine.core.server.server

calculate_and_send_reply_for_message

calculate_and_send_reply_for_message(*, socket: 'zmq.asyncio.Socket', return_address: bytes, msg_contents: str, config: 'FlowmachineServerConfig') -> None
Source: flowmachine/core/server/server.py

Calculate the reply to a zmq message and return the result to the sender. This function is a small wrapper around get_reply_for_message which can be executed as an asyncio background task.

Parameters

  • socket: zmq.asyncio.Socket

    The zmq socket to use for sending the reply.

  • return_address: bytes

    The zmq return address to which to send the reply.

  • msg_contents: str

    JSON string with the message contents.

  • config: FlowmachineServerConfig

    Server config options

get_reply_for_message

get_reply_for_message(*, msg_str: str, config: 'FlowmachineServerConfig') -> flowmachine.core.server.zmq_helpers.ZMQReply
Source: flowmachine/core/server/server.py

Parse the zmq message string, perform the desired action and return the result in JSON format.

Parameters

  • msg_str: str

    The message string as received from zmq. See the docstring of parse_zmq_message for valid structure.

  • config: FlowmachineServerConfig

    Server config options

Returns

  • flowmachine.core.server.zmq_helpers.ZMQReply

    The reply in JSON format.

main

main()
Source: flowmachine/core/server/server.py

receive_next_zmq_message_and_send_back_reply

receive_next_zmq_message_and_send_back_reply(*, socket: 'zmq.asyncio.Socket', config: 'FlowmachineServerConfig') -> None
Source: flowmachine/core/server/server.py

Listen on the given zmq socket for the next multipart message, . Note that the only responsibility of this function is to ensure that the incoming zmq message has the expected structure (three parts of the form return_address, empty_delimiter, msg) and to send back the reply. The responsibility for actually processing the message and calculating the reply lies with other functions.

Parameters

  • socket: zmq.asyncio.Socket

    zmq socket to use for sending the message

  • config: FlowmachineServerConfig

    Server config options

recv

recv(*, config: 'FlowmachineServerConfig') -> NoReturn
Source: flowmachine/core/server/server.py

Main receive-and-reply loop. Listens to zmq messages on the given port, processes them and sends back a reply with the result or an error message.

Parameters

  • config: FlowmachineServerConfig

    Server config options

Returns

  • typing.NoReturn

shutdown

shutdown(socket: 'zmq.asyncio.Socket') -> None
Source: flowmachine/core/server/server.py

Handler for SIGTERM to allow test coverage data to be written during integration tests.