Fix imap cleanup error on abort (#97097)
This commit is contained in:
parent
dc3d0fc7a7
commit
fab3c5b849
1 changed files with 2 additions and 8 deletions
|
@ -298,7 +298,8 @@ class ImapDataUpdateCoordinator(DataUpdateCoordinator[int | None]):
|
|||
except (AioImapException, asyncio.TimeoutError):
|
||||
if log_error:
|
||||
_LOGGER.debug("Error while cleaning up imap connection")
|
||||
self.imap_client = None
|
||||
finally:
|
||||
self.imap_client = None
|
||||
|
||||
async def shutdown(self, *_: Any) -> None:
|
||||
"""Close resources."""
|
||||
|
@ -370,7 +371,6 @@ class ImapPushDataUpdateCoordinator(ImapDataUpdateCoordinator):
|
|||
|
||||
async def _async_wait_push_loop(self) -> None:
|
||||
"""Wait for data push from server."""
|
||||
cleanup = False
|
||||
while True:
|
||||
try:
|
||||
number_of_messages = await self._async_fetch_number_of_messages()
|
||||
|
@ -412,9 +412,6 @@ class ImapPushDataUpdateCoordinator(ImapDataUpdateCoordinator):
|
|||
await idle
|
||||
|
||||
# From python 3.11 asyncio.TimeoutError is an alias of TimeoutError
|
||||
except asyncio.CancelledError as ex:
|
||||
cleanup = True
|
||||
raise asyncio.CancelledError from ex
|
||||
except (AioImapException, asyncio.TimeoutError):
|
||||
_LOGGER.debug(
|
||||
"Lost %s (will attempt to reconnect after %s s)",
|
||||
|
@ -423,9 +420,6 @@ class ImapPushDataUpdateCoordinator(ImapDataUpdateCoordinator):
|
|||
)
|
||||
await self._cleanup()
|
||||
await asyncio.sleep(BACKOFF_TIME)
|
||||
finally:
|
||||
if cleanup:
|
||||
await self._cleanup()
|
||||
|
||||
async def shutdown(self, *_: Any) -> None:
|
||||
"""Close resources."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue