Exemple #1
0
    def __init__(self):
        # Execute in self.rpc_client:
        for x in range(99999):
            try:
                self.log.info("Creating rpc_client")
                # self.log.info("Current stack:")
                # for line in "\n".join(traceback.format_stack()).strip().split("\n"):
                # 	self.log.info("%s", line.rstrip())
                # self.log.info("------------")

                mp_conf = {"use_bin_type": True}
                self.rpc_client = mprpc.RPCClient(settings.SYNC_RPC_SERVER,
                                                  4315,
                                                  pack_params=mp_conf,
                                                  timeout=90)
                self.log.info("Validating RPC connection")

                self.check_ok()
                return
            except AttributeError as e:
                self.log.error("Failed to create RPC interface?")
                if x > 3:
                    raise e

            except Exception as e:
                if x > 3:
                    raise e
Exemple #2
0
 def __init__(self):
     server_rb = os.path.abspath(os.path.join(os.path.dirname(__file__), 'rb_call_server.rb'))
     def setpgrp():
         os.setpgrp()
     self.proc = subprocess.Popen(['bundle','exec','ruby',server_rb], stdout=subprocess.PIPE, preexec_fn=setpgrp)
     def cleanup():
         RubyObject.session = None
         self.proc.terminate()
     atexit.register( cleanup )
     port = int( self.proc.stdout.readline() )
     self.proc.stdout.close()
     def default(obj):
         return obj.to_msgpack()
     self.client = mprpc.RPCClient('localhost', port, pack_encoding= None, unpack_encoding=None, pack_params = {"default": default}, unpack_params={"raw":False})
     RubyObject.session = self
     self.kernel = RubyObject.cast( self.client.call('get_kernel') )
Exemple #3
0
    def __init__(self, interfacename, server_ip, server_port):
        self.interfacename = interfacename

        # Execute in self.rpc_client:
        for x in range(99999):
            try:
                # Cut-the-corners TCP Client:
                mp_conf = {"use_bin_type": True}
                self.rpc_client = mprpc.RPCClient(server_ip,
                                                  server_port,
                                                  pack_params=mp_conf)

                self.check_ok()
                return
            except Exception as e:
                if x > 3:
                    raise e
Exemple #4
0
    def __init__(self, interfacename):
        self.interfacename = interfacename

        # Execute in self.rpc_client:
        for x in range(99999):
            try:
                self.log.info("Creating rpc_client")
                # self.log.info("Current stack:")
                # for line in "\n".join(traceback.format_stack()).strip().split("\n"):
                # 	self.log.info("%s", line.rstrip())
                # self.log.info("------------")

                self.rpc_client = mprpc.RPCClient(
                    host=settings.RPC_AGENT_HOST,
                    port=4315,
                    pack_params={
                        "use_bin_type": True,
                    },
                    unpack_params={
                        'raw': True,
                        'max_buffer_size': 2**31 - 1,
                        'max_str_len': 2**31 - 1,
                        'max_bin_len': 2**31 - 1,
                        'max_array_len': 2**31 - 1,
                        'max_map_len': 2**31 - 1,
                        'max_ext_len': 2**31 - 1,
                    },
                )

                self.log.info("Validating RPC connection")

                # self.rpc_client = self.rpc.get_peer_proxy(timeout=10)
                self.check_ok()
                return
            except AttributeError as e:
                self.log.error("Failed to create RPC interface?")
                if x > 3:
                    raise e

            except Exception as e:
                if x > 3:
                    raise e
Exemple #5
0
    def __init__(self):
        # Execute in self.rpc_client:
        for x in range(99999):
            try:
                self.log.info("Creating rpc_client")
                mp_conf = {"use_bin_type": True}
                self.rpc_client = mprpc.RPCClient(settings.SYNC_RPC_SERVER,
                                                  4315,
                                                  pack_params=mp_conf,
                                                  timeout=30)
                self.log.info("Validating RPC connection")

                self.check_ok()
                return
            except AttributeError as e:
                self.log.error("Failed to create RPC interface?")
                if x > 3:
                    raise e

            except Exception as e:
                if x > 3:
                    raise e
Exemple #6
0
    def __init__(self, interfacename):
        self.interfacename = interfacename

        # Execute in self.rpc_client:
        for x in range(99999):
            try:
                self.log.info("Creating rpc_client")

                self.rpc_client = mprpc.RPCClient(
                    host=settings.RPC_AGENT_HOST,
                    port=4315,
                    pack_params={"use_bin_type": True},
                    unpack_params={
                        'raw': True,
                        'max_buffer_size': sys.maxsize,
                        # 		'max_str_len'     : sys.maxsize,
                        # 		'max_bin_len'     : sys.maxsize,
                        # 		'max_array_len'   : sys.maxsize,
                        # 		'max_map_len'     : sys.maxsize,
                        # 		'max_ext_len'     : sys.maxsize,
                    },
                )

                self.log.info("Validating RPC connection")

                # self.rpc_client = self.rpc.get_peer_proxy(timeout=10)
                self.check_ok()
                return
            except AttributeError as e:
                self.log.error("Failed to create RPC interface?")
                if x > 3:
                    raise e

            except Exception as e:
                if x > 3:
                    raise e
Exemple #7
0
    def __init__(self, interfacename):
        self.interfacename = interfacename

        # Execute in self.rpc_client:
        for x in range(99999):
            try:
                self.log.info("Creating rpc_client")
                mp_conf = {"use_bin_type": True}
                self.rpc_client = mprpc.RPCClient(settings.RPC_AGENT_HOST,
                                                  4315,
                                                  pack_params=mp_conf)
                self.log.info("Validating RPC connection")

                # self.rpc_client = self.rpc.get_peer_proxy(timeout=10)
                self.check_ok()
                return
            except AttributeError as e:
                self.log.error("Failed to create RPC interface?")
                if x > 3:
                    raise e

            except Exception as e:
                if x > 3:
                    raise e
Exemple #8
0
def setup_rpc(port=6000):
	global rpc_connection
	rpc_connection = mprpc.RPCClient("127.0.0.1", port)
Exemple #9
0
import mprpc
c = mprpc.RPCClient("localhost", 6666)
_, info = c.call("vim_get_api_info")
for f in info["functions"]:
    print(f["name"], f["parameters"], f["return_type"])
info = c.call("vim_get_buffers")
print(info)

Exemple #10
0
 def call(self, method: str, params=None):
     log.debug("connect host=%s port=%s",
               self.addr_parsed.hostname, self.addr_parsed.port)
     cl = mprpc.RPCClient(self.addr_parsed.hostname, self.addr_parsed.port)
     log.debug("call %s(%s)", method, params)
     return cl.call(method, params)
Exemple #11
0
# This can be used to make sure connections are handled asynchronously by the
# server, in the example are example/server.rs.
#
# Run it with:
#
# ```
# python issue19.py & ; sleep 2 ; python issue19.py
# ```
#
# The expectation is that the second instance of this script should finish
# within 7 seconds.
#
# This example requires https://github.com/studio-ousia/mprpc
import os
import time
import mprpc

pid = os.getpid()
print(f'{pid}: {time.time()}: client connecting')
client = mprpc.RPCClient('127.0.0.1', 54321)
print(f'{pid}: {time.time()}: client connected, sending request')
client.call('do_long_computation', 5)
print(f'{pid}: {time.time()}: got response')