Advertisement
here2share

# thread_timer.py

Feb 19th, 2016
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.24 KB | None | 0 0
  1. # thread_timer.py
  2.  
  3. from threading import Timer
  4. import time
  5.  
  6. go=True
  7. def timeout():
  8.     global go
  9.     go=False
  10.  
  11. t = Timer(5, timeout)
  12. t.start()
  13.  
  14. # do something else, such as...
  15. i=0
  16. while go:
  17.     print i,'\t',
  18.     i+=1
  19.  
  20. print '\n... Bye!'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement