Skip to content

Commit d24f962

Browse files
thecodechemelli74
andauthored
Do not shutdown device upon errors (#587)
* Do not shutdown device upon errors * Apply suggestions from code review Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> --------- Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com>
1 parent 12c4ed5 commit d24f962

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

aioshelly/block_device/device.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,18 +175,15 @@ async def initialize(self) -> None:
175175
else:
176176
self._last_error = DeviceConnectionError(err)
177177
_LOGGER.debug("host %s: error: %r", ip, self._last_error)
178-
await self.shutdown()
179178
raise self._last_error from err
180179
except MacAddressMismatchError as err:
181180
self._last_error = err
182181
_LOGGER.debug("host %s: error: %r", ip, err)
183-
await self.shutdown()
184182
raise
185183
except CONNECT_ERRORS as err:
186184
self._last_error = DeviceConnectionError(err)
187185
_LOGGER.debug("host %s: error: %r", ip, self._last_error)
188-
await self.shutdown()
189-
raise DeviceConnectionError(err) from err
186+
raise self._last_error from err
190187
finally:
191188
self._initializing = False
192189

aioshelly/rpc_device/device.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,18 +192,15 @@ async def initialize(self) -> None:
192192
except InvalidAuthError as err:
193193
self._last_error = InvalidAuthError(err)
194194
_LOGGER.debug("host %s:%s: error: %r", ip, port, self._last_error)
195-
await self._disconnect_websocket()
196195
raise
197196
except MacAddressMismatchError as err:
198197
self._last_error = err
199198
_LOGGER.debug("host %s:%s: error: %r", ip, port, err)
200-
await self._disconnect_websocket()
201199
raise
202200
except (*CONNECT_ERRORS, RpcCallError) as err:
203201
self._last_error = DeviceConnectionError(err)
204202
_LOGGER.debug("host %s:%s: error: %r", ip, port, self._last_error)
205-
await self._disconnect_websocket()
206-
raise DeviceConnectionError(err) from err
203+
raise self._last_error from err
207204
finally:
208205
self._initializing = False
209206

0 commit comments

Comments
 (0)