python at mrabarnett.plus.com
Tue Jun 30 00:32:26 CEST 2009
> hi folks.
> the follwing shoud print 'stuff' for 3 seconds and then stop. why it
> does not work? (prints stuff forever)
> 1 #!/usr/bin/python
> 3 import threading
> 4 import sys
> 6 t = threading.Timer(3.0, sys.exit)
> 7 t.start()
> 8 while True:
> 9 print "stuff ",
The Timer runs the function in another thread. Perhaps sys.exit is just
exiting that thread and not the main thread.
More information about the Python-list