Make server initialization respect DRY a bit more.
authorGeorg Brandl <georg@python.org>
Wed, 3 Oct 2012 20:53:57 +0000 (22:53 +0200)
committerGeorg Brandl <georg@python.org>
Wed, 3 Oct 2012 20:53:57 +0000 (22:53 +0200)
irkerd

diff --git a/irkerd b/irkerd
index 21b8d73b6621435d400188addd51c21801258b0f..80dae8088bffebc0c79f5347988fce51c3d18ee7 100755 (executable)
--- a/irkerd
+++ b/irkerd
@@ -463,13 +463,11 @@ if __name__ == '__main__':
             sys.exit(0)
     irker = Irker(debuglevel=debuglvl)
     tcpserver = SocketServer.TCPServer((HOST, PORT), IrkerTCPHandler)
-    tcpserver = threading.Thread(target=tcpserver.serve_forever)
-    tcpserver.setDaemon(True)
-    tcpserver.start()
     udpserver = SocketServer.UDPServer((HOST, PORT), IrkerUDPHandler)
-    udpserver = threading.Thread(target=udpserver.serve_forever)
-    udpserver.setDaemon(True)
-    udpserver.start()
+    for server in [tcpserver, udpserver]:
+        server = threading.Thread(target=server.serve_forever)
+        server.setDaemon(True)
+        server.start()
     try:
         while True:
             time.sleep(10)