How to use the tinyrpc.dispatch.RPCDispatcher function in tinyrpc

To help you get started, we’ve selected a few tinyrpc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mbr / tinyrpc / tests / test_server.py View on Github external
def dispatcher(response):
    dispatcher = Mock(RPCDispatcher)
    dispatcher.dispatch = Mock(return_value=response)
    return dispatcher
github mbr / tinyrpc / tests / test_dispatch.py View on Github external
def dispatch():
    return RPCDispatcher()
github mbr / tinyrpc / tests / test_dispatch.py View on Github external
def subdispatch():
    return RPCDispatcher()
github MatrixAINetwork / go-matrix / cmd / clef / pythonsigner.py View on Github external
def main(args):

    cmd = ["./clef", "--stdio-ui"]
    if len(args) > 0 and args[0] == "test":
        cmd.extend(["--stdio-ui-test"])
    print("cmd: {}".format(" ".join(cmd)))
    dispatcher = RPCDispatcher()
    dispatcher.register_instance(StdIOHandler(), '')
    # line buffered
    p = subprocess.Popen(cmd, bufsize=1, universal_newlines=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)

    rpc_server = RPCServer(
        PipeTransport(p.stdout, p.stdin),
        JSONRPCProtocol(),
        dispatcher
    )
    rpc_server.serve_forever()
github osrg / ryu / ryu / app / wsgi.py View on Github external
def __init__(self, ws, rpc_callback):
        dispatcher = RPCDispatcher()
        dispatcher.register_instance(rpc_callback)
        super(WebSocketRPCServer, self).__init__(
            WebSocketServerTransport(ws),
            JSONRPCProtocol(),
            dispatcher,
        )
github MatrixAINetwork / go-matrix / run / clef / pythonsigner.py View on Github external
def main(args):

    cmd = ["./clef", "--stdio-ui"]
    if len(args) > 0 and args[0] == "test":
        cmd.extend(["--stdio-ui-test"])
    print("cmd: {}".format(" ".join(cmd)))
    dispatcher = RPCDispatcher()
    dispatcher.register_instance(StdIOHandler(), '')
    # line buffered
    p = subprocess.Popen(cmd, bufsize=1, universal_newlines=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)

    rpc_server = RPCServer(
        PipeTransport(p.stdout, p.stdin),
        JSONRPCProtocol(),
        dispatcher
    )
    rpc_server.serve_forever()
github osrg / ryu / ryu / contrib / tinyrpc / transports / INTEGRATE_ME.py View on Github external
response = dispatcher.dispatch(request)
                log.debug('Response okay: %r', response)

            # send reply
            message[-1] = response.serialize()
            log.debug('Replying %s to %r', message[-1], message[0])
            socket.send_multipart(message)

        gevent.spawn(handle_client, message)


context = zmq.Context()
socket = context.socket(zmq.ROUTER)
socket.bind("tcp://127.0.0.1:12345")

dispatcher = RPCDispatcher()

@dispatcher.public
def throw_up():
    return 'asad'
    raise Exception('BLARGH')

rpc_server(socket, JSONRPCProtocol(), dispatcher)
github heikoheiko / pydevp2p / devp2p / jsonrpc.py View on Github external
def __init__(self, app):
        log.debug('initializing JSONRPCServer')
        BaseService.__init__(self, app)
        self.app = app
        self.dispatcher = RPCDispatcher()
        transport = WsgiServerTransport(queue_class=gevent.queue.Queue)

        # start wsgi server as a background-greenlet
        self.wsgi_server = gevent.wsgi.WSGIServer(('127.0.0.1', 5000), transport.handle)

        self.rpc_server = RPCServerGreenlets(
            transport,
            JSONRPCProtocol(),
            self.dispatcher
        )