Skip to content

Commit 4a72266

Browse files
committed
fix: hold a strong reference to the query sender task
fixes #1126
1 parent ef09683 commit 4a72266

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Diff for: src/zeroconf/_services/browser.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ def _async_start(self) -> None:
329329
self.query_scheduler.start(current_time_millis())
330330
self.zc.async_add_listener(self, [DNSQuestion(type_, _TYPE_PTR, _CLASS_IN) for type_ in self.types])
331331
# Only start queries after the listener is installed
332-
asyncio.ensure_future(self._async_start_query_sender())
332+
self._query_sender_task = asyncio.ensure_future(self._async_start_query_sender())
333333

334334
@property
335335
def service_state_changed(self) -> SignalRegistrationInterface:
@@ -436,6 +436,7 @@ def _async_cancel(self) -> None:
436436
self.done = True
437437
self._cancel_send_timer()
438438
self.zc.async_remove_listener(self)
439+
self._query_sender_task.cancel()
439440

440441
def _generate_ready_queries(self, first_request: bool, now: float) -> List[DNSOutgoing]:
441442
"""Generate the service browser query for any type that is due."""

0 commit comments

Comments
 (0)