Python threading.Timer是否创建新线程?
我正在尝试实现一个可用的Python RTDserver。我遇到了一些关于不能将COM对象与多个线程一起使用的错误,我正试图在本文中解决这个问题 我现在正在努力理解部分代码 它使用线程库,特别是计时器函数。这会创建一个实际的新线程吗?还是只是一个暂停?正如您所能看到的,Update函数是递归调用的,并且是函数的结尾Python threading.Timer是否创建新线程?,python,multithreading,timer,Python,Multithreading,Timer,我正在尝试实现一个可用的Python RTDserver。我遇到了一些关于不能将COM对象与多个线程一起使用的错误,我正试图在本文中解决这个问题 我现在正在努力理解部分代码 它使用线程库,特别是计时器函数。这会创建一个实际的新线程吗?还是只是一个暂停?正如您所能看到的,Update函数是递归调用的,并且是函数的结尾 def Update(self): # Get our wake-up thread ready... self.ticker = threadin
def Update(self):
# Get our wake-up thread ready...
self.ticker = threading.Timer(self.INTERVAL, self.Update)
try:
# Check if any of our topics have new info to pass on
if len(self.topics):
refresh = False
for topic in self.topics.values():
topic.Update(self)
if topic.HasChanged():
refresh = True
topic.Reset()
if refresh:
self.SignalExcel()
finally:
self.ticker.start() # Make sure we get to run again
此类表示一个操作,该操作应仅在经过一定时间后运行—计时器。Timer是Thread的一个子类,因此也可以作为创建自定义线程的示例。
请参阅: