Skip to content

Commit 263576f

Browse files
committed
feat: improve performance of ServiceBrowser outgoing query scheduler
closes #821 The bulk of the time was spent checking to see if queries were ready to go out from the reschedule which checks every type the ServiceBrowser has configured. Since we are only adjusting one type we can guard this with a simple check to avoid checking every type
1 parent 90410a2 commit 263576f

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎src/zeroconf/_services/browser.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,13 +460,15 @@ def _cancel_send_timer(self) -> None:
460460
"""Cancel the next send."""
461461
if self._next_send_timer:
462462
self._next_send_timer.cancel()
463+
self._next_send_timer = None
463464

464465
def reschedule_type(self, type_: str, now: float, next_time: float) -> None:
465466
"""Reschedule a type to be refreshed in the future."""
466467
if self.query_scheduler.reschedule_type(type_, next_time):
467468
self._cancel_send_timer()
468469
self._async_schedule_next(now)
469-
self._async_send_ready_queries(now)
470+
if now >= next_time:
471+
self._async_send_ready_queries(now)
470472

471473
def _async_send_ready_queries(self, now: float) -> None:
472474
"""Send any ready queries."""

0 commit comments

Comments
 (0)