mhthies / smarthomeconnect

Python 3 AsyncIO-based home automation and interfacing framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simultaneous updates of connected variables may cause inconsistent states

mhthies opened this issue · comments

When multiple variables are connectected (e.g. in server-client scenarios) and two value updates arrive at the same time (from "different sides"), the value updates may probably "cross over" and result in inconsistent states and different orders of outgoing updates.

The problem is verified and reproducable in tests.

Current proposed solution: Add an internal mutex object to every stateful subscribable object, which is locked during value update and publishing. The mutex is inherited to all subscribers during setup phase, such that every "network" of objects, connected via subscriptions, shares a single mutex, so all value updates within that network are serialized.