|
25 | 25 | import random |
26 | 26 | import threading |
27 | 27 | import warnings |
| 28 | +from abc import abstractmethod |
28 | 29 | from collections import OrderedDict |
29 | 30 | from typing import ( |
30 | 31 | TYPE_CHECKING, |
@@ -408,21 +409,14 @@ def async_update_records(self, zc: 'Zeroconf', now: float, records: List[RecordU |
408 | 409 | for record in records: |
409 | 410 | self._async_process_record_update(now, record[0], record[1]) |
410 | 411 |
|
| 412 | + @abstractmethod |
411 | 413 | def async_update_records_complete(self) -> None: |
412 | 414 | """Called when a record update has completed for all handlers. |
413 | 415 |
|
414 | 416 | At this point the cache will have the new records. |
415 | 417 |
|
416 | 418 | This method will be run in the event loop. |
417 | 419 | """ |
418 | | - while self._pending_handlers: |
419 | | - event = self._pending_handlers.popitem(False) |
420 | | - # If there is a queue running (ServiceBrowser) |
421 | | - # get fired in dedicated thread |
422 | | - if self.queue: |
423 | | - self.queue.put(event) |
424 | | - else: |
425 | | - self._fire_service_state_changed_event(event) |
426 | 420 |
|
427 | 421 | def _fire_service_state_changed_event(self, event: Tuple[Tuple[str, str], ServiceStateChange]) -> None: |
428 | 422 | """Fire a service state changed event. |
@@ -553,3 +547,14 @@ def run(self) -> None: |
553 | 547 | if event is None: |
554 | 548 | return |
555 | 549 | self._fire_service_state_changed_event(event) |
| 550 | + |
| 551 | + def async_update_records_complete(self) -> None: |
| 552 | + """Called when a record update has completed for all handlers. |
| 553 | +
|
| 554 | + At this point the cache will have the new records. |
| 555 | +
|
| 556 | + This method will be run in the event loop. |
| 557 | + """ |
| 558 | + assert self.queue is not None |
| 559 | + while self._pending_handlers: |
| 560 | + self.queue.put(self._pending_handlers.popitem(False)) |
0 commit comments