我很难搞清楚为什么程序无限期暂停,即表现出无限循环的行为
def class foo():
'''
...
'''
def __catcher(self, signum, _):
print "TIME OUT EXCEEDED"
# Reset timer
signal.setitimer(signal.ITIMER_REAL, 0.0, _SENDERTMOUT_)
# Do something
for i in range (self.base, self.next_seqno):
'''
...
'''
def start(self):
while something:
'''
Start doing some work
'''
if self.base == self.next_seqno:
old_handler = signal.signal(signal.SIGALRM, self.__catcher)
signal.setitimer(signal.ITIMER_REAL, _SENDERTMOUT_)
'''
Do more work until timer goes off
'''
也许我不知道执行的顺序,当start()中的计时器超时时,程序会跳转到__catcher(),对吗?然后重置计时器,然后声明的其余部分然后程序在哪里恢复执行?
感谢您的帮助!
答案 0 :(得分:0)
我猜它会回到计时器中断的地方?