I didn't go into all the details, but in general i'd go for something as
described here:
http://rpyc.readthedocs.org/en/latest/docs/howto.html#tunneling
But since you already have rpyc installed on the "common host", things
should be even easier -- connect over rpyc to the common host, use it's
rpyc module to connect to the end host, and you should be done. just keep
in mind this introduces a lag, and you have to keep the underlying
connection open while the second one operates, but any tunnel suffers from
these artifacts.
here's what i had in mind:
import rpyc
conn1 = rpyc.connect("common-host")
conn2 = conn1.modules["rpyc"].connect("end-host")
-tomer
-----------------------------------------------------------------
*Tomer Filiba*
tomerfiliba.com <http://www.facebook.com/tomerfiliba>
<http://il.linkedin.com/in/tomerfiliba>
On Fri, Jul 25, 2014 at 3:26 PM, <[email protected]> wrote:
> Hello,
>
> I am fairly new to RPyC so I am probably missing something here.
> I try to implement the following scenario:
>
> I have several JobClients, which should execute some jobs
> Then, I have a JobManager, which holds a list of jobs to execute.
>
> Problem: Both cannot connect directly to each other, due to firewalls.
>
> So, I have a third component, called dispatcher on a host which can be
> reached from everyone.
> The idea is to have the manager service exposed over the dispatcher to the
> client, who asks for jobs.
> In my implementation the Dispatcher saves the root object of the
> management service and exposes it for the clients.
>
> But, as soon as one client tries to called a function of the manager
> service, the client freezes.
> The debugger shows that it hangs in stream.py line 48.
>
> A MWE might look like this:
> dispatcher.py: (has to started first)
>
> import rpyc
> class SimpleDispatcherService(rpyc.Service):
>
> exposed_manager_root = None
>
> def on_connect(self):
> pass
>
> def on_disconnect(self):
> pass
>
> def exposed_register_manager(self):
> SimpleDispatcherService.exposed_manager_root = self._conn.root
>
> if __name__ == "__main__":
> from rpyc.utils.server import ThreadedServer
> t = ThreadedServer(SimpleDispatcherService, port=18861,
> protocol_config = {"allow_public_attrs" : True})
> t.start()
>
> manager.py (has to started second):
> import time
> import rpyc
>
>
> class SimpleManagerService(rpyc.Service):
>
> def on_connect(self):
> pass
>
> def on_disconnect(self):
> pass
>
> def exposed_get_my_jobs(self, hostname):
> return ["Test", ]
>
>
> class SimpleManager:
>
> def __init__(self):
> self.conn = None
>
> def start(self):
> self.conn = rpyc.connect("localhost", 18861, service=
> SimpleManagerService)
> self.conn.root.register_manager()
>
> def run(self):
> while True:
> time.sleep(1)
>
>
>
> if __name__ == "__main__":
> myManager = SimpleManager()
> myManager.start()
> myManager.run()
>
> client.py (has to be started last:)
> import rpyc
> class SimpleClient:
> def __init__(self):
> pass
>
> def run(self):
> conn = rpyc.connect("localhost", 18861)
> print("Connected fetching processes")
> new_processes = conn.root.manager_root.get_my_jobs("Test")
> print(new_processes)
>
> if __name__ == "__main__":
> myClient = SimpleClient()
> myClient.run()
>
> This prints "Connected fetching processes" but hangs afterwards.
> My setup: python3.2 on Ubuntu precise 64 with virtualenv and rpyc 3.3
> installed via pip
>
> Any help appreciated
>
> Regards,
> Hannes Riechmann
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "rpyc" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
---
You received this message because you are subscribed to the Google Groups
"rpyc" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.