|
31 | 31 | from ._services.types import ZeroconfServiceTypes |
32 | 32 | from ._utils.aio import wait_condition_or_timeout |
33 | 33 | from ._utils.net import IPVersion, InterfaceChoice, InterfacesType |
34 | | -from ._utils.time import current_time_millis, millis_to_seconds |
| 34 | +from ._utils.time import millis_to_seconds |
35 | 35 | from .const import ( |
36 | 36 | _BROWSER_TIME, |
37 | 37 | _CHECK_TIME, |
38 | | - _LISTENER_TIME, |
39 | 38 | _MDNS_PORT, |
40 | 39 | _REGISTER_TIME, |
41 | 40 | _SERVICE_TYPE_ENUMERATION_NAME, |
@@ -66,38 +65,6 @@ def update_service(self, aiozc: 'AsyncZeroconf', type_: str, name: str) -> None: |
66 | 65 | class AsyncServiceInfo(ServiceInfo): |
67 | 66 | """An async version of ServiceInfo.""" |
68 | 67 |
|
69 | | - async def async_request(self, aiozc: 'AsyncZeroconf', timeout: float) -> bool: |
70 | | - """Returns true if the service could be discovered on the |
71 | | - network, and updates this object with details discovered. |
72 | | - """ |
73 | | - if self.load_from_cache(aiozc.zeroconf): |
74 | | - return True |
75 | | - |
76 | | - now = current_time_millis() |
77 | | - delay = _LISTENER_TIME |
78 | | - next_ = now |
79 | | - last = now + timeout |
80 | | - await aiozc.zeroconf.async_wait_for_start() |
81 | | - try: |
82 | | - aiozc.zeroconf.add_listener(self, None) |
83 | | - while not self._is_complete: |
84 | | - if last <= now: |
85 | | - return False |
86 | | - if next_ <= now: |
87 | | - out = self.generate_request_query(aiozc.zeroconf, now) |
88 | | - if not out.questions: |
89 | | - return self.load_from_cache(aiozc.zeroconf) |
90 | | - aiozc.zeroconf.async_send(out) |
91 | | - next_ = now + delay |
92 | | - delay *= 2 |
93 | | - |
94 | | - await aiozc.zeroconf.async_wait(min(next_, last) - now) |
95 | | - now = current_time_millis() |
96 | | - finally: |
97 | | - aiozc.zeroconf.remove_listener(self) |
98 | | - |
99 | | - return True |
100 | | - |
101 | 68 |
|
102 | 69 | class AsyncServiceBrowser(_ServiceBrowserBase): |
103 | 70 | """Used to browse for a service of a specific type. |
@@ -333,7 +300,7 @@ async def async_get_service_info( |
333 | 300 | name and type, or None if no service matches by the timeout, |
334 | 301 | which defaults to 3 seconds.""" |
335 | 302 | info = AsyncServiceInfo(type_, name) |
336 | | - if await info.async_request(self, timeout): |
| 303 | + if await info.async_request(self.zeroconf, timeout): |
337 | 304 | return info |
338 | 305 | return None |
339 | 306 |
|
|
0 commit comments