|
2 | 2 |
|
3 | 3 | from __future__ import annotations |
4 | 4 |
|
| 5 | +import asyncio |
5 | 6 | import json |
6 | 7 | import logging |
7 | 8 | from typing import Any |
@@ -185,12 +186,12 @@ async def login(self) -> bool: |
185 | 186 | log = f"Login failed with status {response.status}. Full Response: {response.text}" |
186 | 187 | _LOGGER.error(log) |
187 | 188 | raise AirOSConnectionAuthenticationError from None |
188 | | - except ( |
189 | | - aiohttp.ClientError, |
190 | | - aiohttp.client_exceptions.ConnectionTimeoutError, |
191 | | - ) as err: |
| 189 | + except (TimeoutError, aiohttp.client_exceptions.ClientError) as err: |
192 | 190 | _LOGGER.exception("Error during login") |
193 | 191 | raise AirOSDeviceConnectionError from err |
| 192 | + except asyncio.CancelledError: |
| 193 | + _LOGGER.info("Login task was cancelled") |
| 194 | + raise |
194 | 195 |
|
195 | 196 | def derived_data( |
196 | 197 | self, response: dict[str, Any] | None = None |
@@ -301,12 +302,12 @@ async def status(self) -> AirOSData: |
301 | 302 | response_text, |
302 | 303 | ) |
303 | 304 | raise AirOSDeviceConnectionError |
304 | | - except ( |
305 | | - aiohttp.ClientError, |
306 | | - aiohttp.client_exceptions.ConnectionTimeoutError, |
307 | | - ) as err: |
308 | | - _LOGGER.error("Status API call failed: %s", err) |
| 305 | + except (TimeoutError, aiohttp.client_exceptions.ClientError) as err: |
| 306 | + _LOGGER.exception("Status API call failed: %s", err) |
309 | 307 | raise AirOSDeviceConnectionError from err |
| 308 | + except asyncio.CancelledError: |
| 309 | + _LOGGER.info("API status retrieval task was cancelled") |
| 310 | + raise |
310 | 311 |
|
311 | 312 | async def stakick(self, mac_address: str = None) -> bool: |
312 | 313 | """Reconnect client station.""" |
@@ -339,12 +340,12 @@ async def stakick(self, mac_address: str = None) -> bool: |
339 | 340 | log = f"Unable to restart connection response status {response.status} with {response_text}" |
340 | 341 | _LOGGER.error(log) |
341 | 342 | return False |
342 | | - except ( |
343 | | - aiohttp.ClientError, |
344 | | - aiohttp.client_exceptions.ConnectionTimeoutError, |
345 | | - ) as err: |
346 | | - _LOGGER.exception("Error during reconnect request call") |
| 343 | + except (TimeoutError, aiohttp.client_exceptions.ClientError) as err: |
| 344 | + _LOGGER.exception("Error during call to reconnect remote: %s", err) |
347 | 345 | raise AirOSDeviceConnectionError from err |
| 346 | + except asyncio.CancelledError: |
| 347 | + _LOGGER.info("Reconnect task was cancelled") |
| 348 | + raise |
348 | 349 |
|
349 | 350 | async def provmode(self, active: bool = False) -> bool: |
350 | 351 | """Set provisioning mode.""" |
@@ -378,9 +379,9 @@ async def provmode(self, active: bool = False) -> bool: |
378 | 379 | log = f"Unable to change provisioning mode response status {response.status} with {response_text}" |
379 | 380 | _LOGGER.error(log) |
380 | 381 | return False |
381 | | - except ( |
382 | | - aiohttp.ClientError, |
383 | | - aiohttp.client_exceptions.ConnectionTimeoutError, |
384 | | - ) as err: |
385 | | - _LOGGER.exception("Error during provisioning mode call") |
| 382 | + except (TimeoutError, aiohttp.client_exceptions.ClientError) as err: |
| 383 | + _LOGGER.exception("Error during call to change provisioning mode: %s", err) |
386 | 384 | raise AirOSDeviceConnectionError from err |
| 385 | + except asyncio.CancelledError: |
| 386 | + _LOGGER.info("Provisioning mode change task was cancelled") |
| 387 | + raise |
0 commit comments