Skip to content

Send requests that execute third party functions from a remote package #2063

Closed Answered by wigging
wigging asked this question in Q&A
Discussion options

You must be logged in to vote

Based on your suggestions, here is my client and server code:

# client.py

import zmq
from typing import Any

class Client:
    """Client for sending/receiving messages."""

    def __init__(self, address="tcp://localhost:5555"):
        context = zmq.Context()
        socket = context.socket(zmq.REQ)
        socket.connect(address)
        self.socket = socket

    def _send_message(self, function: str, *args: Any):
        msg = {"func": function, "args": args}
        self.socket.send_json(msg)

    def _recv_message(self) -> Any:
        msg: Any = self.socket.recv_json()
        return msg["result"]

    def get_serial_number(self) -> str:
        """Get serial number from remote fun…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@wigging
Comment options

@minrk
Comment options

minrk Feb 4, 2025
Maintainer

@wigging
Comment options

Answer selected by wigging
# for free to join this conversation on GitHub. Already have an account? # to comment
Category
Q&A
Labels
None yet
2 participants