How can I schedule a task to run every 10 seconds in Python?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Haiyan
    New Member
    • Jul 2010
    • 17

    How can I schedule a task to run every 10 seconds in Python?

    Dear Experts:

    I am writing one test program with Python which is running multiple threads in parallel. I hope to add another thread to display the test status every 10 seconds. Could you please tell me how I can schedule a task to run every 10 seconds in Python?

    I defined one function return_status() and tried the Timer object of threading as follows, but it only run once after 10 seconds. I hope it can run multiple times and invoke every 10 seconds.

    Code:
    running_status = threading.Timer(10, self.return_status)    # return test status every 10 seconds
    running_status.start()
    Thank you very much in advance!

    Regards,
    Haiyan
Working...