1# You can not restart a thread in python
2# However you can make sure it stays alive forever
3# If threads ending is a problem just loop them forever
4
5# Example:
6import threading
7import time
8
9class mythreader(threading.Thread):
10 def __init__(self):
11 threading.Thread.__init__(self)
12 self.setDaemon(True)
13 self.running = True
14 self.start()
15
16 def run(self):
17 mycounter = 0
18 while self.running:
19 do_some_cool_stuff()
20 time.sleep(2)