Exemplo n.º 1
0
    def test_simulation_call(self):
        def f(x, y):
            return x + y
        
        import types
        from distributed import RemoteProtocol
        import sys

        data = []
        result = []
        protocol = RemoteProtocol(result.append, data.pop)
        data += [("finished", protocol.wrap(5)), ("finished", protocol.wrap(f))]
        fun = protocol.get_remote("f")
        assert isinstance(fun, types.FunctionType)
        assert fun(2, 3) == 5
Exemplo n.º 2
0
def socket_loop(address, to_export, socket=socket):
    from distributed import RemoteProtocol, remote_loop
    try:
        send, receive = socket_listener(address, socket)
        remote_loop(RemoteProtocol(send, receive, to_export))
    except Finished:
        pass
Exemplo n.º 3
0
    def test_simulation_call(self):
        def f(x, y):
            return x + y

        import types
        from distributed import RemoteProtocol
        import sys

        data = []
        result = []
        protocol = RemoteProtocol(result.append, data.pop)
        data += [("finished", protocol.wrap(5)),
                 ("finished", protocol.wrap(f))]
        fun = protocol.get_remote("f")
        assert isinstance(fun, types.FunctionType)
        assert fun(2, 3) == 5
Exemplo n.º 4
0
def spawn_remote_side(code, gw):
    """ A very simple wrapper around greenexecnet to allow
    spawning a remote side of lib/distributed
    """
    from distributed import RemoteProtocol
    extra = str(py.code.Source("""
    from distributed import remote_loop, RemoteProtocol
    remote_loop(RemoteProtocol(channel.send, channel.receive, globals()))
    """))
    channel = gw.remote_exec(code + "\n" + extra)
    return RemoteProtocol(channel.send, channel.receive)
Exemplo n.º 5
0
def local():
    send, receive = socket_connecter(('localhost', PORT))
    return RemoteProtocol(send, receive)
Exemplo n.º 6
0
def remote():
    send, receive = socket_listener(address=('', PORT))
    remote_loop(RemoteProtocol(send, receive, globals()))
Exemplo n.º 7
0
def connect(address, socket=socket):
    from distributed.support import RemoteView
    from distributed import RemoteProtocol
    return RemoteView(RemoteProtocol(*socket_connecter(address, socket)))