From: Eric S. Raymond Date: Thu, 4 Oct 2012 18:35:09 +0000 (-0400) Subject: Arrange to restart dead delivery threads. X-Git-Tag: 1.7~16 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=28c9985f087d883b8fee5c5be54711eb3cf20b21;p=irker.git Arrange to restart dead delivery threads. --- diff --git a/irkerd b/irkerd index 36cd9b1..9ffa945 100755 --- a/irkerd +++ b/irkerd @@ -117,9 +117,7 @@ class Connection: self.channel_limits = {} # The consumer thread self.queue = Queue.Queue() - self.thread = threading.Thread(target=self.dequeue) - self.thread.setDaemon(True) - self.thread.start() + self.thread = None def nickname(self, n=None): "Return a name for the nth server connection." if n is None: @@ -160,6 +158,10 @@ class Connection: self.status = "ready" def enqueue(self, channel, message): "Enque a message for transmission." + if self.thread is None or not self.thread_is_alive(): + self.thread = threading.Thread(target=self.dequeue) + self.thread.setDaemon(True) + self.thread.start() self.queue.put((channel, message)) def dequeue(self): "Try to ship pending messages from the queue."