我创建了一个线程,它每60秒执行一次,就像计时器或SetInterval一样,基于此:Python threading.timer - repeat function every 'n' seconds
它在Windows上总是工作得很好,但是现在我必须在Linux上执行这个命令(Fedora和Ubuntu,现在),它就是不工作!你知道吗
我不知道为什么,因为它不返回任何错误。我的快照功能在线程外运行良好。你知道吗
这是我的密码:
class ShotAllTheTime(Thread):
"""
Thread principal que invoca as operações do Client
"""
def __init__(self, event, time_between_shots = 60, *args, **kwargs):
Thread.__init__(self)
self.finished = event
self.time_between_shots = time_between_shots
self.args = args
self.kwargs = kwargs
def cancel(self):
#Termina a thread.
self.finished.set()
def run(self):
while not self.finished.wait(self.time_between_shots):
Shot()
这就是我如何称呼ShotAllTheTime线程:
def main()
stop_shots = Event()
MyThread = ShotAllTheTime(stop_shots)
MyThread.start()
while 1:
entrada = raw_input("\nEnter 'exit' to exit:")
if entrada == 'exit':
stop_shots.set()
break
sys.exit()
main()
目前没有回答
相关问题 更多 >
编程相关推荐