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
