SHARE
TWEET

Daemon thread

a guest Aug 14th, 2012 25 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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()
RAW Paste Data
Want to get better at Python?
Learn to code Python in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top