How can I make classical timer in gevent?
I’m currently using gevent.spawn_later but is there a way to use core.timer like saying “do callback on interval” just like cron does?
def callback():
# do something
print '!'
timer = core.timer(10, callback)
timer.start()
outpout:
0s
10s !
20s !
30s !
On the top of my head, you can use gevent.sleep in a loop:
Of course, you may put this code in a nice API such as core.timer. But I’ll let all the fun for you 🙂