Open danjampro opened 3 years ago
They used to unregister themselves, it was in the camera server (now service) __del__()
method. It's impossible to guarantee that gets run though, as it relies on Python being allowed to clean up properly. If the OoM killer just splats the Python process or the Pi hard resets no Python code is going to be able to ensure the remote object gets unregistered.
Because of that we also set the name server to automatically unregister any remote objects that it was unable to contact for a set timeout time, in order to clean up in case a camera server died without managing to unregister itself.
Have these features been translated to the new Pyro5 setup?
I like the idea of checking for and removing duplicates, though.
I thought we'd attempt to reboot a pi fast enough so that the name server doesn't know it has gone offline?
@AnthonyHorton would this work:
if self.config['pyro']['reboot_on_failure']:
self.logger.debug(f"Rebooting computer hosting camera {self._camera}")
self._camera.__del__()
time.sleep(5)
subprocess_args = ["sudo", "reboot", "now"]
If a pyro device is terminated (or crashes), it should unregister itself on the name server. Additionally, when starting a new pyro service, we should unregister any pyro object with the same service name to prevent registration errors.
This is particularly important for getting the restart on reboot working properly.