python - 有没有办法拒绝预定的计时器事件?

标签 python multithreading

考虑一下这一点。我想拒绝执行计时器事件:

import threading


def say_hello():
    print 'hello'

threading.Timer(10, say_hello, ()).start()
# now for some reason my plans have changed
# is there a way to erase that Timer and deny execution of say_hello?

最佳答案

t = threading.Timer(10, say_hello, ())
t.start()  # start timer
t.cancel()  # stop it

关于python - 有没有办法拒绝预定的计时器事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39411757/

相关文章:

java - StreamCorruptedException : invalid type code: AC

python - 了解 os.fork 和 Queue.Queue

python - 使用python下载sharepoint 365文档

python - 从 Pandas 的日期时间变量中删除时间?

c# - 通过 C# 中的 COM RCW 对象检测跨线程编码

C# + SQLite - 数据库锁

Python Memoryview 与 Bytearray?

python - 获取多个值

python - 字典的字典到 DataFrame

c# - 如何通过任务使用 Clipboard.GetText?