From 6d1370cc2aa6d2c125aa924342e224b6b92ef8d9 Mon Sep 17 00:00:00 2001 From: Stephen Rauch Date: Sun, 26 Jun 2016 15:56:53 -0700 Subject: [PATCH] Delay connecting ServiceBrowser() until it is running --- zeroconf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zeroconf.py b/zeroconf.py index b2277168c..57a1cc608 100644 --- a/zeroconf.py +++ b/zeroconf.py @@ -1078,8 +1078,6 @@ def __init__(self, zc, type_, handlers=None, listener=None): self.done = False - self.zc.add_listener(self, DNSQuestion(self.type, _TYPE_PTR, _CLASS_IN)) - if hasattr(handlers, 'add_service'): listener = handlers handlers = None @@ -1147,6 +1145,8 @@ def cancel(self): self.join() def run(self): + self.zc.add_listener(self, DNSQuestion(self.type, _TYPE_PTR, _CLASS_IN)) + while True: now = current_time_millis() if len(self._handlers_to_call) == 0 and self.next_time > now: