views:

65

answers:

2

I have small repeater Below that keeps ending, How can fix so more stable from crashes, and not stop running.... I would I add a heartbeat to the gui to see that its still running. In Wxpthon, my menu bar goes blank or white.

 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)
A: 

This runs for 7000 iterations. So if your runtime is at about 7000*300 s, it "works exactly as coded" :-) However, possibly the number of threads or the things you do in FetchUpdates could be a problem. Is there any traceback when it stops? Are reaching a user limit?

knitti
There are no traceback's, just stops. dead. I use a simple gui with buttom, which stays depressed, when running.
whats the code when you press the gui button. Obviously it doesn't return
knitti
pressing the button, executes the timersetup. the timer code executes internet fetch into db. then redo. I have "try" code for internet fail, does not fire. ...reworking--internet process...
Thats what you want what it does. Please show me the code which gets executed as event handler. Code for event handlers should return quickly, because until it returns the GUI doesn't get redrawn. Thats exactly what you're experiencing.
knitti
Knitti, thanks.... there were conficts in FetchUpdates....
A: 

seems you need join() to wait the start thread

 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)
Gunslinger_
why would I need a join?
because you need to wait the end for thread.start() then start new thread and go on. or thread just doing start thread without end it that causing crash
Gunslinger_