[wingide-users] problems with threading.Timer
Wingware Support
support at wingware.com
Wed Nov 7 12:19:58 MST 2007
Sebastian Fey wrote:
> i got a program that uses the threading.Timer object.
> when debugging with wing-ide the timer is only started once, whats the
> problem?
>
> ###############
> import threading
>
> def test( v0, v1, v2 ):
> print "test", v0, v1, v2
> if v1 < 5:
> print "run timers"
> threading.Timer( 1, test, [], {"v0":v0+1,"v1":v1+1,"v2":v2+1}
> ).start()
>
> if __name__ == "__main__":
> print __name__
> test(1,2,3)
> ###############
The issue here is that the main thread exits while the sub-threads are
still running and inside the debugger sub-threads are killed when the
main thread exits. You can work around this by adding something like
this at the end of the code:
import time
time.sleep(10)
We'll try to fix this but there were some subtleties involved that I
need to look up and understand again.
--
Stephan Deibel
Wingware | Python IDE
Advancing Software Development
www.wingware.com
More information about the wingide-users
mailing list