Skip to content

Commit

Permalink
Avoid creating tasks to process zeroconf updates (#364)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Feb 27, 2024
1 parent 59a0078 commit 4a06745
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions aiohomekit/controller/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def state_num(self) -> bytes | None:
return self._accessories_state.state_num

@abstractmethod
async def _process_disconnected_events(self):
def _process_disconnected_events(self):
"""Process any disconnected events that are available."""

def _callback_listeners(self, event):
Expand Down Expand Up @@ -203,7 +203,7 @@ def _async_description_update(
"%s: Disconnected event notification received; Triggering catch-up poll",
self.name,
)
async_create_task(self._process_disconnected_events())
self._process_disconnected_events()

self.description = description

Expand Down
9 changes: 6 additions & 3 deletions aiohomekit/controller/ble/pairing.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,10 @@ async def _async_pair_verify(self) -> None:
self._session_id = session_id
self._derive = derive

async def _process_disconnected_events(self) -> None:
def _process_disconnected_events(self) -> None:
async_create_task(self._async_process_disconnected_events())

async def _async_process_disconnected_events(self) -> None:
"""Handle disconnected events seen from the advertisement."""
if not self._tried_to_connect_once:
# We never tried connected to the accessory, so we don't need to
Expand Down Expand Up @@ -664,7 +667,7 @@ def _async_notification(self, data: HomeKitEncryptedNotification) -> None:
self.name,
data,
)
async_create_task(self._process_disconnected_events())
self._process_disconnected_events()
return

if not self.description:
Expand Down Expand Up @@ -741,7 +744,7 @@ def _async_notification(self, data: HomeKitEncryptedNotification) -> None:
self.name,
data,
)
async_create_task(self._process_disconnected_events())
self._process_disconnected_events()

def _async_get_service_signature_char(self) -> Characteristic | None:
"""Get the service signature characteristic."""
Expand Down
2 changes: 1 addition & 1 deletion aiohomekit/controller/coap/pairing.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ async def _process_config_changed(self, config_num: int) -> None:
)
self._callback_and_save_config_changed(config_num)

async def _process_disconnected_events(self):
def _process_disconnected_events(self):
"""Process any events that happened while we were disconnected.
We don't disconnect in COAP so there is no need to do anything here.
Expand Down
2 changes: 1 addition & 1 deletion aiohomekit/controller/ip/pairing.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ async def _process_config_changed(self, config_num: int) -> None:
)
self._callback_and_save_config_changed(self.config_num)

async def _process_disconnected_events(self):
def _process_disconnected_events(self):
"""Process any events that happened while we were disconnected.
We don't disconnect in IP so there is no need to do anything here.
Expand Down

0 comments on commit 4a06745

Please sign in to comment.