This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Daemon thread

By: a guest on Aug 14th, 2012  |  syntax: Python  |  size: 0.38 KB  |  views: 22  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/python
  2.  
  3. import threading
  4. import time
  5.  
  6. class Update(threading.Thread):
  7.     def __init__(self):
  8.         threading.Thread.__init__(self)
  9.  
  10.     def run(self):
  11.         while True:
  12.             with open('/tmp/log.txt', 'w') as f:
  13.                 f.write('%d\n' % time.time())
  14.                 time.sleep(1.0)
  15.  
  16. continous = Update()
  17. continous.daemon = True
  18. continous.start()
clone this paste RAW Paste Data