Arrange to restart dead delivery threads.
authorEric S. Raymond <esr@thyrsus.com>
Thu, 4 Oct 2012 18:35:09 +0000 (14:35 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Thu, 4 Oct 2012 18:35:09 +0000 (14:35 -0400)
irkerd

diff --git a/irkerd b/irkerd
index 36cd9b1d65caa217e0ecab63b30ddd85e32afe56..9ffa945b62dd4baa3db7bc80365885c35a904c20 100755 (executable)
--- 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."