@@ -0,0 +1,1146 @@
+try:%0A    import Queue as queue%0Aexcept ImportError:%0A    import queue%0A%0Afrom dss.tools import thread%0A%0A%0Aclass WebsocketBroadcast(thread.Thread):%0A    def __init__(self, cls):%0A        %22%22%22 %60cls%60 must be a class providing a list/set of%0A            connected websocket clients (cls.clients) and%0A            a lock to access said list (cls.lock).%0A%0A            All clients must be %60tornado.websocket.WebSocketHandler%60%0A            instances.%0A        %22%22%22%0A        super(WebsocketBroadcast, self).__init__()%0A        self.name = type(self).__name__%0A        self.queue = queue.Queue()%0A        self.running = False%0A        self.cls = cls%0A%0A    def add_message(self, message):%0A        self.queue.put(message)%0A%0A    def run(self):%0A        self.running = True%0A        while self.running:%0A            message = self.queue.get()%0A            if message is None:%0A                break%0A            with self.cls.lock:%0A                clients = list(self.cls.clients)%0A            for client in clients:%0A                client.write_message(message)%0A%0A    def stop(self):%0A        self.running = False%0A        self.queue.empty()%0A        self.queue.put(None)%0A        self.join()%0A

Add an websocket broadcasting feature