From: Eric S. Raymond Date: Sat, 30 Nov 2013 12:31:56 +0000 (-0500) Subject: Refactoring step: don't uncomditionally spawn a thread... X-Git-Tag: 2.3~8 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a6bbbb2bbea6dac98feff82326346d09dc2b5971;p=irker.git Refactoring step: don't uncomditionally spawn a thread... ...immediate mode doesn't need it. --- diff --git a/irkerd b/irkerd index ddc008c..f7a1adc 100755 --- 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)