Search code examples
pythonpyrochordpyro4

Pyro4 kill empty nameserver


I am using Pyro4 in a distributed system. My problem is that after two networks connect there can be many nameserver. It is ok for me but if any of them is empty (has no objects registered) my network can fail . This is because I am implementing chord and I need to know if there is any chord node running already (if the empty nameserver responds then two chord rings will be created. Is there any way to kill a nameserver if it is empty?
My code is in python3. Thanks


Solution

  • Pyro's name server assumes it is running all the time: you never know if there will be someone a bit later that wants to register a new name. If you really need it to auto shutdown, you'll have to either wrap the default name server in some custom code, or use some form of watchdog process that kills the name server if it detects that it has 0 entries.

    You can get the number of entries via a regular Pyro call to the nameserver: ns.count(). For obvious reasons, it's not possible to remotely shutdown the nameserver via such a Pyro API call, hence the need of a watch dog process.