Remote Procedure Call¶
Connector can do RPC in a easy way. It can call functions, call system commands and run scripts on remote computer. In following description, client means client object on client side, means client peer on server side.
client.eval(statement, block = True): Let remote computer call pythonevaland get return value.statement: The string of Python code.block: IfblockisTrue, it will block process until remoteevalreturns. Otherwise it will immediately return aFutureobject which you can callresult()on it to get real return value.
client.exec(code, block = True): Let remote computer call pythonexecand get return value. Usage just likeclient.eval.client.execfile(local_script_path, block=True): Let remote computer run a local python script.local_script_path: Script file path on local computer.block: IfblockisTrue, it will block process until remote computer run script finished. Otherwise, it will immediately return aFutureobject which you can callresult()on to wait it finished.
client.exec_remote_file(remote_script_path, block=True): Let remote computer run a remote python script. The usage is just likeclient.execfile.client.system(cmd, quiet=False, remote_quiet=False, once_all=False, block=True): Let remote computer run system command.cmd: System command string need to be call.quiet: IfquietisTrue, local side won’t print anything of standard output and standard error.remote_quiet: If it’sTrue, remote side won’t print anything of standard output and standard error.once_all: Local and remote side won’t print anything during system call processing and will print message after system finished.block: IfblockisTrue, it will block process until system call finished and return system call’s return value. Otherwise, it will immediately return aFutureobject which you can callresult()on it to get system call’s return value.
client.call(function, args=(), kwargs={}, block=True): Let remote computer call a local function.function: A local callable python object, for exampleprintis OK.args: Function’s positional arguments need to be passed.kwargs: Function’s key words arguments need to be passed.block: IfblockisTrue, it will block process until remote computer call this function finished and return this function calling return value. Otherwise, it will immediately return aFutureobject which you can callresult()on it to get function calling return value.
client.call_remote(function_name, args=(), kwargs={}, block=True): Let remote computer call a remote function.function_name: A remote function name string, for example"print"is OK.args: Function’s positional arguments need to be passed.kwargs: Function’s key words arguments need to be passed.block: IfblockisTrue, it will block process until remote computer call this function finished and return this function calling return value. Otherwise, it will immediately return aFutureobject which you can callresult()on it to get function calling return value.