本文整理汇总了Python中threading.Timer.getName方法的典型用法代码示例。如果您正苦于以下问题:Python Timer.getName方法的具体用法?Python Timer.getName怎么用?Python Timer.getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类threading.Timer
的用法示例。
在下文中一共展示了Timer.getName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: NamedTimer
# 需要导入模块: from threading import Timer [as 别名]
# 或者: from threading.Timer import getName [as 别名]
def NamedTimer(*args,**kwargs):
t = Timer(*args,**kwargs)
t.setDaemon(True)
t.setName("NamedTimer"+t.getName())
return t
示例2: basicConfig
# 需要导入模块: from threading import Timer [as 别名]
# 或者: from threading.Timer import getName [as 别名]
basicConfig(level=DEBUG, format="(%(threadName)s) %(message)s",)
def myThread():
debug("myThread running")
thread1 = Timer(3, myThread)
thread1.setName("Thread1")
thread2 = Timer(3, myThread)
thread2.setName("Thread2")
debug("starting timers")
thread1.start()
thread2.start()
debug("waiting before canceling %s", thread2.getName())
sleep(2)
debug("canceling %s", thread2.getName())
thread2.cancel()
print("Main thread is done")
##################################################
#
# $ timerthreads.py
# (MainThread) starting timers
# (MainThread) waiting before canceling Thread2
# (MainThread) canceling Thread2
# Main thread is done
# (Thread1) myThread running
#