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 pythoneval
and get return value.statement
: The string of Python code.block
: Ifblock
isTrue
, it will block process until remoteeval
returns. Otherwise it will immediately return aFuture
object which you can callresult()
on it to get real return value.
client.exec(code, block = True)
: Let remote computer call pythonexec
and 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
: Ifblock
isTrue
, it will block process until remote computer run script finished. Otherwise, it will immediately return aFuture
object 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
: Ifquiet
isTrue
, 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
: Ifblock
isTrue
, it will block process until system call finished and return system call’s return value. Otherwise, it will immediately return aFuture
object 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 exampleprint
is OK.args
: Function’s positional arguments need to be passed.kwargs
: Function’s key words arguments need to be passed.block
: Ifblock
isTrue
, it will block process until remote computer call this function finished and return this function calling return value. Otherwise, it will immediately return aFuture
object 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
: Ifblock
isTrue
, it will block process until remote computer call this function finished and return this function calling return value. Otherwise, it will immediately return aFuture
object which you can callresult()
on it to get function calling return value.