From 1a288e07cc9b2c8139d45c787c2078de61766850 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 2 Apr 2016 22:44:27 +0800 Subject: [PATCH] protocols/remote_exec: simplify, use global namespace --- artiq/protocols/remote_exec.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/artiq/protocols/remote_exec.py b/artiq/protocols/remote_exec.py index be0bf3642..45928040c 100644 --- a/artiq/protocols/remote_exec.py +++ b/artiq/protocols/remote_exec.py @@ -2,33 +2,27 @@ from functools import partial import inspect from artiq.protocols.pc_rpc import simple_server_loop -from artiq.protocols.pc_rpc import Client as RPCClient __all__ = ["RemoteExecServer", "RemoteExecClient", "simple_rexec_server_loop"] class RemoteExecServer: - def __init__(self, target): - self.target = target - self.namespace = dict() + def __init__(self, initial_namespace): + self.namespace = dict(initial_namespace) def add_code(self, code): exec(code, self.namespace) def call(self, function, *args, **kwargs): - return self.namespace[function](self, *args, **kwargs) - - -class RemoteExecClient(RPCClient): - def transfer_obj_source(self, obj): - self.add_code(self, inspect.getsource(obj)) + return self.namespace[function](*args, **kwargs) def simple_rexec_server_loop(target_name, target, host, port, description=None): + initial_namespace = {"controller_driver": target} targets = { target_name: target, - target_name + "_rexec": lambda: RemoteExecServer(target) + target_name + "_rexec": lambda: RemoteExecServer(initial_namespace) } simple_server_loop(targets, host, port, description)