Skip to content

Commit

Permalink
Fixed: Button exception when container is recreated
Browse files Browse the repository at this point in the history
Changed: Improved aidocker exceptions
  • Loading branch information
ualex73 committed Jun 26, 2024
1 parent 6303db6 commit eb8681b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion custom_components/monitor_docker/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def event_callback(self, name="", remove=False) -> None:
return

_LOGGER.info("[%s] %s: Removing button entity", self._instance, self._cname)
self._loop.create_task(self.async_remove())
asyncio.create_task(self.async_remove())
self._removed = True
return

Expand Down
19 changes: 17 additions & 2 deletions custom_components/monitor_docker/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,9 +751,17 @@ async def _initGetContainer(self) -> bool:

try:
self._container = await self._api.containers.get(self._name)
except aiodocker.exceptions.DockerError as err:
_LOGGER.error(
"[%s] %s: Container not available anymore (2a) (%s)",
self._instance,
self._name,
str(err),
)
return False
except Exception as err:
_LOGGER.error(
"[%s] %s: Container not available anymore (2) (%s)",
"[%s] %s: Container not available anymore (2b) (%s)",
self._instance,
self._name,
str(err),
Expand Down Expand Up @@ -795,9 +803,16 @@ async def _run(self) -> None:
)
pass
break
except aiodocker.exceptions.DockerError as err:
_LOGGER.error(
"[%s] %s: Container not available anymore (3a) (%s)",
self._instance,
self._name,
str(err),
)
except Exception as err:
_LOGGER.error(
"[%s] %s: Container not available anymore (3) (%s)",
"[%s] %s: Container not available anymore (3b) (%s)",
self._instance,
self._name,
str(err),
Expand Down

0 comments on commit eb8681b

Please sign in to comment.