feat: significantly improve efficiency of the ServiceBrowser scheduler by bdraco · Pull Request #1335 · python-zeroconf/python-zeroconf

The query scheduled was sub-optimal because we will schedule a query in the future when a PTR will be close to expiring, but if the PTR is seen again between when it was scheduled and we ask again, we still ask. This lead to an order of magnitude (frequently even 2 orders of magnitude) more queries than needed to rescue records from expiration.

This is a complete rewrite of the ServiceBrowser query scheduler.

fixes #821
replaces and closes #1171

Work tracking:

  • units for _ScheduledPTRQuery
  • units for QueryScheduler
  • unit for schedule_rescue_query
  • test for type being rescheduled
  • pr splits
  • remove prints and debug
  • refactor test_asking_qu/qm_questions to be more reliable
  • handle retries convert time back to expire %, and if less than 100%, schedule for later in 10% increments
  • investigate why Smart Bridge 2 is sometimes missing. It's only responding to qm. So we need to keep the qu first and than fallback to qm