Closed sooryranga closed 4 years ago
No, the instance mode 'single' makes Pyro take care to create the object only once.
Your output is not reproducible behavior (I see just one "Called" being printed at all times) There has to be something else going on in your code. You're probably creating an instance of Animals somewhere else in your code.
What Pyro version are you using? Have you tried the 'instancemode' examples that come with Pyro?
I do have a Gunicorn which tries to access animals instance :
workers = min(cpu_count(), 4)
timeout = 300
preload_app = True
def on_starting(server):
animals = Proxy("PYRONAME:" + PYRO_DECODER_APP_NAME)
while True:
try:
animals.wait_till_ready()
break
except NamingError:
pass
I have : Pyro4 (4.78)
Since there is no lock on: https://github.com/irmen/Pyro4/blob/9fd891c1cf33530cd263f83ed7f805317474a48c/src/Pyro4/core.py#L1535-L1543
Wouldn't there be a chance that multiple calls to pyro-ns result in multiple initialization of animals
if animals take a long time to be created ( ie init in animals take a long time) ?
Hmm. If this proves to be an issue, I will perhaps not fix it in Pyro4 but only in Pyro5.
This was a trivial fix actually, thanks for reporting
I registered an object with :
Called it with serveSimple:
This results in :
Does pyro4 expects animal object to be a singleton? or is it taken care of when we specify
instance_mode="single"
?