timer
MRAB
python at mrabarnett.plus.com
Mon Jun 29 18:32:26 EDT 2009
superpollo wrote:
> 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
> 2
> 3 import threading
> 4 import sys
> 5
> 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
mailing list