I'd like to know how to efficiently check if a variable has had a change in value and if it did, to return this value. For the moment I have something like this:
while(True):
if paramCHK == x:
// do this
elif paramCHK == y:
// do that
// and that
// and that
The problem with above implementation is that when I am in the elif-clause and the parameter changes to x, this is not detected as the execution time of the clause is too long.
What I had in mind is to create a thread and monitor the parameter constantly in a parallel fashion and when a change is detected, report it to the main-function:
myThread():
if paramCHK.changed():
notify_main()
main():
when notification:
getParamValue()
// do something depending the value
How would you solve this in python? Thanks in advance