I have a written python code for real time system in which I am acquiring the data from one functions and assigning it to a variable which is actually a global variable but when I tried to use it in other functions I am unable to get updated value in other functions. How to get rid of this problem. Sample code which will give an elaborate idea what I am exactly doing is as follows.
obtained_value = 0
### Inside the continuous loop statement ###
def Startloop(self):
global obtained_value
obtained_value = acquire_data() ## obtained value is getting updated after every 0.25 seconds ##
## other statements ##
def some_functions(self):
### want to do something which depend on value ###
print obtained_value ## does not print value inside "obtained_value"
val1 = obtained_value * 10
print val1
## etc etc ###
I am not getting any value printed corresponding to print statement inside the some_function. Its seems like value of global variable is not getting updated. How to fix this problem. Any suggestion will be appreciated. Thanks in advance.