Pythonで60秒ごとに関数を実行したいのですが、その間ブロックされたくありません。
どうすれば非同期で実行できますか?
import threading
import time
def f():
print("hello world")
threading.Timer(3, f).start()
if __name__ == '__main__':
f()
time.sleep(20)
このコードでは、関数fは20秒のtime.time内で3秒ごとに実行されます。最後にエラーが発生しますが、これはthreading.timerがキャンセルされていないためだと思います。
どうすればキャンセルできますか?
前もって感謝します!