diff --git a/src/zeroconf/_core.py b/src/zeroconf/_core.py index 0264f72a..40375484 100644 --- a/src/zeroconf/_core.py +++ b/src/zeroconf/_core.py @@ -240,7 +240,7 @@ async def async_wait_for_start(self) -> None: raise NotRunningException @property - def listeners(self) -> List[RecordUpdateListener]: + def listeners(self) -> Set[RecordUpdateListener]: return self.record_manager.listeners async def async_wait(self, timeout: float) -> None: diff --git a/src/zeroconf/_handlers/record_manager.pxd b/src/zeroconf/_handlers/record_manager.pxd index 7a55e64f..e0792d72 100644 --- a/src/zeroconf/_handlers/record_manager.pxd +++ b/src/zeroconf/_handlers/record_manager.pxd @@ -12,11 +12,12 @@ cdef object RecordUpdate cdef object TYPE_CHECKING cdef object _TYPE_PTR + cdef class RecordManager: cdef public object zc cdef public DNSCache cache - cdef public cython.list listeners + cdef public cython.set listeners cpdef async_updates(self, object now, object records) @@ -29,3 +30,7 @@ cdef class RecordManager: now_float=cython.float ) cpdef async_updates_from_response(self, DNSIncoming msg) + + cpdef async_add_listener(self, object listener, object question) + + cpdef async_remove_listener(self, object listener) diff --git a/src/zeroconf/_handlers/record_manager.py b/src/zeroconf/_handlers/record_manager.py index dcbe5e91..586fba0b 100644 --- a/src/zeroconf/_handlers/record_manager.py +++ b/src/zeroconf/_handlers/record_manager.py @@ -45,7 +45,7 @@ def __init__(self, zeroconf: 'Zeroconf') -> None: """Init the record manager.""" self.zc = zeroconf self.cache = zeroconf.cache - self.listeners: List[RecordUpdateListener] = [] + self.listeners: Set[RecordUpdateListener] = set() def async_updates(self, now: _float, records: List[RecordUpdate]) -> None: """Used to notify listeners of new information that has updated @@ -175,7 +175,7 @@ def async_add_listener( " In the future this will fail" ) - self.listeners.append(listener) + self.listeners.add(listener) if question is None: return diff --git a/src/zeroconf/_services/info.py b/src/zeroconf/_services/info.py index 7ca8d29b..1ffd9570 100644 --- a/src/zeroconf/_services/info.py +++ b/src/zeroconf/_services/info.py @@ -758,10 +758,6 @@ def generate_request_query( question.unicast = True return out - def __eq__(self, other: object) -> bool: - """Tests equality of service name""" - return isinstance(other, ServiceInfo) and other._name == self._name - def __repr__(self) -> str: """String representation""" return '{}({})'.format(