我有小型转发器下面不断结束,怎么能从崩溃中解决这么稳定,而不是停止运行.... 我会向gui添加一个心跳,看它还在运行。在Wxpthon中,我的菜单栏变为空白或白色。
def TimerSetup():
import threading, time
invl = 300
def dothis():
try:
FetchUpdates()
except Exception as e:
pass
class Repeat(threading.Thread):
def run(self):
dothis()
if __name__ == '__main__':
for x in range(7000):
thread = Repeat(name = "Thread-%d" % (x + 1))
thread.start()
time.sleep(invl)
答案 0 :(得分:0)
这将运行7000次迭代。因此,如果您的运行时间大约为7000 * 300秒,它“完全按照编码工作”:-)但是,您在FetchUpdates中执行的线程数或事情可能是个问题。它停止时有没有追溯?达到用户限制?
答案 1 :(得分:0)
似乎你需要join()来等待启动线程
def TimerSetup():
import threading, time
invl = 300
def dothis():
try:
FetchUpdates()
except Exception as e:
pass
class Repeat(threading.Thread):
def run(self):
dothis()
if __name__ == '__main__':
for x in range(7000):
thread = Repeat(name = "Thread-%d" % (x + 1))
thread.start()
thread.join()
time.sleep(invl)