2

I have wrote below code for the purpose of that repeteadly runn/stop function in another function. But, it is awkward. Are there a beauty way to do run/stop one function in another function. In other words, run a function in every 2 seconds but if function which run other one is terminated, the other should be stopped. ( I have wrote it with Timer().start )

Assume that there is a schedule function, which used to simulate what I want

  def foo():
         print 2
         arg = 10
         schedule(5, bar, arg).start()
         while True :
             if q_pressed():
                 schedule(5, bar, arg1).stop()

 def bar(arg):
        print arg
demilg
  • 77
  • 6
  • possible duplicate of [Python threading.timer - repeat function every 'n' seconds](http://stackoverflow.com/questions/12435211/python-threading-timer-repeat-function-every-n-seconds) – miku Mar 18 '13 at 09:24
  • 1
    @miku, they are not same – demilg Mar 18 '13 at 10:12

0 Answers0