discoverer: Check to make sure info is real before using
This fixes a related issue in discovery when a removal occurs before the
announcement is complete.
Change-Id: I1c2dc2c4bfd29ef9e7a7225c39b0377f5d43d691
diff --git a/mdt/discoverer.py b/mdt/discoverer.py
index 46ce367..bbe31a5 100644
--- a/mdt/discoverer.py
+++ b/mdt/discoverer.py
@@ -70,11 +70,12 @@
def remove_service(self, zeroconf, type, name):
info = self.zeroconf.get_service_info(type, name)
- self._heard_announcement = True
- if self.listener and hasattr(self.listener, "remove_device"):
- self.listener.remove_device(info.server,
- self.discoveries[info.server])
+ if info:
+ if self.listener and hasattr(self.listener, "remove_device"):
+ self.listener.remove_device(info.server,
+ self.discoveries[info.server])
- if info.server in self.discoveries:
- del(self.discoveries[info.server])
+ if info.server in self.discoveries:
+ self._heard_announcement = True
+ del(self.discoveries[info.server])