Skip to content

Commit

Permalink
fix: deadlock when connection is lost during register read
Browse files Browse the repository at this point in the history
  • Loading branch information
mukaschultze committed Mar 5, 2024
1 parent e594081 commit f4f37de
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions custom_components/must_inverter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,11 @@ async def read_modbus_data(self):

try:
_LOGGER.debug("reading modbus data from %s to %s (%s)", start, end, count)
async with self._lock:
if not await self._check_and_reopen():
break

if not await self._check_and_reopen():
break

async with self._lock:
response = await self._client.read_holding_registers(address=start, count=count, slave=0x04)
if response.isError():
_LOGGER.error("error reading modbus data at address %s: %s", start, response)
Expand Down

0 comments on commit f4f37de

Please sign in to comment.