1
# gozerbot/threadloop.py
5
""" class to implement start/stoppable threads """
7
__copyright__ = 'this file is in the public domain'
9
from gozerbot.generic import rlog
10
from gozerbot.thr import start_new_thread
13
class ThreadLoop(object):
15
def __init__(self, name):
20
self.queue = Queue.Queue()
23
rlog(5, self.name, 'starting loop')
25
while not self.stopped:
26
data = self.queue.get()
30
rlog(5, self.name, 'stopping loop')
33
self.queue.put_nowait(data)
37
start_new_thread(self._loop, ())