Solve modbus shutdown racing condition (#55373)

This commit is contained in:
jan iversen 2021-08-28 23:04:33 +02:00 committed by GitHub
parent 13cc671844
commit f91cc21bbd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -292,8 +292,8 @@ class ModbusHub:
for call in self.entity_timers:
call()
self.entity_timers = []
if self._client:
async with self._lock:
if self._client:
try:
self._client.close()
except ModbusException as exception_error:
@ -327,9 +327,9 @@ class ModbusHub:
"""Convert async to sync pymodbus call."""
if self._config_delay:
return None
async with self._lock:
if not self._client:
return None
async with self._lock:
result = await self.hass.async_add_executor_job(
self._pymodbus_call, unit, address, value, use_call
)