How to launch a function at regular time intervals ?

David davigier at
Sat Aug 15 00:28:06 CEST 2009

With your help, Franck, I think I finally got it to work. This is how
I did it:

# In the main program, launch the 2 threads CStoreData and
CTransferData, which will run indefinitely until they are stopped (if
the threads were launched inside the while loop, there would be an
infinitely growing number of threads CStoreData all doing the same
thing, same for CTransferData)

func_store_data = CStoreData()

func_transfer_data = CTransferData()

# While loop, just to keep the threads running until they are stopped
at the end of the program. If there wasn't a while loop, the threads
would be stopped right after they are launched. The while loop
separates the "start" of the threads from the "stop" of the threads

while 1
  if end_condition:  # terminate program
            break  # break out of while loop

# Stop all running threads at end



Again thanks a lot to all of you for your precious help.


More information about the Python-list mailing list