python - Threading.Timer(5, function) launch every 5 second -


i'm having hard hard time timer function threading.

basically, when program starts, want log stats every x second.

so thought timer function (launch function every 5 second).

for now, did :

from threading import timer def startlogger():     while true:         t = timer(5, function)         t.start()   def function():     print("hey") 

but launch error, think it's not way it.

runtimeerror: can't start new thread

if can give me clue, appreciated!

you can try following. idea is, scheduling next function call @ end of function's body:

import threading  def mylog():   print "hey" ` threading.timer(5.0, mylog)`.start()  mylog() 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -