I am attempting to call a Pyro object method p1.get_name()
from another remote Pyro object p2
. The method should return the name of the p1
object, but it is returning nothing (empty string). Surprisingly, I see that p1
is accessible from p2
because when I invoke p1.print_hello()
, it works. It seems that a new instance is passed rather than the one initialized, I am not sure what is going on. Please have a look at the following code, thank you for your help!
The following piece of code creates the proxies (for readability, I ignored the name server and creating the daemons):
def create_proxy(ns_host, thing_host):
ns = Pyro4.locateNS(host=ns_host)
uri = ns.lookup(thing_host)
return Pyro4.Proxy(uri)
p1 = create_proxy('localhost', 'host1')
p1.init()
p2 = create_proxy('localhost', 'host2')
p2.init(p1)
The class definitions for p1 and p2 objects appear as follows:
Class Host1:
def __init__(self)
self.name = ''
def init(sut):
self.name = 'host 1'
def get_name(self):
return self.name
Class Host2:
def init(p):
print('Host name: ', p.get_name())
Cheers, /Nas