Speed up restart when bluetooth adapter is in a failed state (#80640)

This commit is contained in:
J. Nick Koston 2022-10-20 09:35:09 -05:00 committed by GitHub
parent 884f8d6e2c
commit da14acb3b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -385,15 +385,11 @@ class HaScanner(BaseHaScanner):
async def async_stop(self) -> None:
"""Stop bluetooth scanner."""
async with self._start_stop_lock:
await self._async_stop()
async def _async_stop(self) -> None:
"""Cancel watchdog and bluetooth discovery under the lock."""
if self._cancel_watchdog:
self._cancel_watchdog()
self._cancel_watchdog = None
await self._async_stop_scanner()
async with self._start_stop_lock:
await self._async_stop_scanner()
async def _async_stop_scanner(self) -> None:
"""Stop bluetooth discovery under the lock."""