Skip to content

Commit 949c85c

Browse files
committed
Fix startup race
1 parent dc65112 commit 949c85c

2 files changed

Lines changed: 2 additions & 7 deletions

File tree

zeroconf/_services/__init__.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,8 @@ def __init__(
307307
for h in handlers:
308308
self.service_state_changed.register_handler(h)
309309

310+
self.zc.add_listener(self, [DNSQuestion(type_, _TYPE_PTR, _CLASS_IN) for type_ in self.types])
311+
310312
@property
311313
def service_state_changed(self) -> SignalRegistrationInterface:
312314
return self._service_state_changed.registration_interface
@@ -406,11 +408,6 @@ def cancel(self) -> None:
406408
self.done = True
407409
self.zc.remove_listener(self)
408410

409-
def run(self) -> None:
410-
"""Run the browser."""
411-
questions = [DNSQuestion(type_, _TYPE_PTR, _CLASS_IN) for type_ in self.types]
412-
self.zc.add_listener(self, questions)
413-
414411
def generate_ready_queries(self) -> List[DNSOutgoing]:
415412
"""Generate the service browser query for any type that is due."""
416413
now = current_time_millis()
@@ -480,7 +477,6 @@ def cancel(self) -> None:
480477

481478
def run(self) -> None:
482479
"""Run the browser thread."""
483-
super().run()
484480
while True:
485481
timeout = self._seconds_to_wait()
486482
if timeout:

zeroconf/aio.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ async def async_cancel(self) -> None:
146146

147147
async def async_run(self) -> None:
148148
"""Run the browser task."""
149-
self.run()
150149
await self.aiozc.zeroconf.async_wait_for_start()
151150
while True:
152151
timeout = self._seconds_to_wait()

0 commit comments

Comments
 (0)