Skip to content

Commit

Permalink
fix(fhempy): release readingsBeginUpdate lock after 120s if no readin…
Browse files Browse the repository at this point in the history
…gsEndUpdate received
  • Loading branch information
fhempy committed Dec 17, 2022
1 parent cc1414b commit 3607d18
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion FHEM/bindings/python/fhempy/lib/fhem.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,13 @@ async def setDevAttrList(name, attr_list):
async def readingsBeginUpdate(hash):
if hash["NAME"] not in update_locks:
update_locks[hash["NAME"]] = asyncio.Lock()
await update_locks[hash["NAME"]].acquire()
try:
await asyncio.wait_for(update_locks[hash["NAME"]].acquire(), 120)
except asyncio.TimeoutError:
logging.error(
f"{hash['NAME']}: readingsBeginUpdate couldn't acquire lock,"
+ " caused by readingsBeginUpdate without End or Single update inbetween"
)
cmd = "readingsBeginUpdate($defs{'" + hash["NAME"] + "'});;"
return await sendCommandHash(hash, cmd)

Expand Down

0 comments on commit 3607d18

Please sign in to comment.