[Tutor] (no subject)

Jeff Peery jeffpeery at yahoo.com
Tue Nov 30 23:04:45 CET 2004


hello again, 
 
I am thoroughly confused. I am using Timer from the threading module. I want to check a specific file every few minutes to see if it has been altered (I do this by checking the size of the file using stat) if it hasn't then I do nothing, if it has then I attempt to read the file, grab all the new numerical data and update a graph on my computer. 
 
this file I am reading holds liquid volumetric flow rate measurement data and the python code I am writing is to be used as a statistical process control. basically I watch the results from the measurements by watching a particular file for updates, when an update occurs I grab the data do some more stats, then update my graphs that show on my desktop.
 
the timer I used is a class, so I defined a new object (I think thats the right word) as:
 
    myTimer = Timer(30.0, Update)
 
where the timer runs every 30 seconds and Update is a function that checks if the file has been altered and if so then it updates my graphs. I then start the timer:
 
    myTimer.start()
 
I am confused by two things:
1) I want my timer to restart every 30 seconds. as it shows above it will go just one time. If I put this in a while loop, will the while loop loop through the start command faster than 30 second intervals or will it wait for the timer to execute the Update function before calling timer.start() again?
2) I am also confused about how variables are handled when I have multiple and nested functions. for example, I would like to initiate the Update function every 30 seconds and I want the Update funtion to return any new data. how can I return something from a function when the function is called from a timer? I cannot do an assignment statement from within the definnition of myTimer? or do I even need to return the data? if I create a variable in the update function is it available in my main function? I am not sure how python handles variables that are defined in different functions.
 
thank you very much for spending the time to help me, I appreciate it!
 
Jeff
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20041130/77cfdb8b/attachment.html


More information about the Tutor mailing list