-1

I am writing a GUI Python code which should be run every 15 minutes, however when it runs it took more than that (15 minutes +running time). The function I am using is,

animation.FuncAnimation(f,animate,interval=900000)

is there anyway to make the interval variable?

using time.sleep is not good option as this will lead to freezing the GUI screen, I am using Tkinter which is thread unsafe

Thanks in Advance,

pcs
  • 1,864
  • 4
  • 25
  • 49

1 Answers1

0

Note: These are more of hack then a nice solution but should work.

  1. You could make the function running time deterministic? in-python-how-can-i-put-a-thread-to-sleep-until-a-specific-time Then reduce the function running time from the interval.

  2. Or as you have alluded to in your question you could calculate/buffer the results of the function in a separate thread.

If the function is running in the GUI thread (as it probably is) solution 2 is nicer as it will stop the GUI from becoming unresponsive when the function is running.

Community
  • 1
  • 1
pev.hall
  • 467
  • 4
  • 8
  • Thanks for your reply,I am trying to run away from threading as Tkinter is Thread unsafe, is there any function that can repeat the execution from the starting time of the last run? – Mr Programmer Apr 22 '15 at 07:14
  • Thread unsafe is not a reason not to use threads. It just means you need to take care with the data structures shared between the threads. I don't know of any function like the one you are after. – pev.hall Apr 22 '15 at 23:04