0

我有一个小的中继器在它下面一直结束,如何修复更稳定的崩溃,而不是停止运行....我会在 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)
4

2 回答 2

0

这将运行 7000 次迭代。因此,如果您的运行时间约为 7000*300 秒,它“完全按照编码工作”:-) 但是,线程数或您在 FetchUpdates 中执行的操作可能是个问题。停止时是否有任何回溯?是否达到用户限制?

于 2010-09-20T20:10:51.983 回答
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)
于 2010-09-22T04:40:40.013 回答