Refactoring step: don't uncomditionally spawn a thread...
authorEric S. Raymond <esr@thyrsus.com>
Sat, 30 Nov 2013 12:31:56 +0000 (07:31 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Sat, 30 Nov 2013 12:31:56 +0000 (07:31 -0500)
...immediate mode doesn't need it.

irkerd

diff --git a/irkerd b/irkerd
index ddc008c5895bbe30651424a8c7e1bb26f59155f4..f7a1adc7e7bcdfe3ae89c2b0e1b2714bf672b7c3 100755 (executable)
--- a/irkerd
+++ b/irkerd
@@ -683,11 +683,12 @@ class Irker:
         self.irc.add_event_handler("disconnect", self._handle_disconnect)
         self.irc.add_event_handler("kick", self._handle_kick)
         self.irc.add_event_handler("every_raw_message", self._handle_every_raw_message)
+        self.servers = {}
+    def thread_launch(self):
         thread = threading.Thread(target=self.irc.spin)
         thread.setDaemon(True)
         self.irc._thread = thread
         thread.start()
-        self.servers = {}
     def logerr(self, errmsg):
         "Log a processing error."
         sys.stderr.write("irkerd: " + errmsg + "\n")
@@ -872,6 +873,7 @@ if __name__ == '__main__':
         irker.irc.spin()
         # FIXME: This mode does not yet terminate
     else:
+        irker.thread_launch()
         try:
             tcpserver = SocketServer.TCPServer((HOST, PORT), IrkerTCPHandler)
             udpserver = SocketServer.UDPServer((HOST, PORT), IrkerUDPHandler)