練習:
from threading import Timer
import time
def tick_run():
print("timer wakeup")
class RepeatingTimer(Timer):
def run(self):
while not self.finished.is_set():
self.function(*self.args,**self.kwargs)
self.finished.wait(self.interval)
t=RepeatingTimer(5.0,tick_run)
t.start()
while True:
time.sleep(1)
print("main wakeup")
不錯的文章:
https://www.twblogs.net/a/5c894d8ebd9eee35fc148ca6
沒有留言:
張貼留言