server: externalize and streamline mixin setup
authorDirkjan Ochtman <djc.ochtman@kentyde.com>
Thu, 11 Mar 2010 13:28:39 +0100
changeset 10639 a6808629f450
parent 10638 92209ae8610a
child 10640 90a095c24bc4
server: externalize and streamline mixin setup
mercurial/hgweb/server.py
--- a/mercurial/hgweb/server.py	Thu Mar 11 11:21:48 2010 +0100
+++ b/mercurial/hgweb/server.py	Thu Mar 11 13:28:39 2010 +0100
@@ -195,8 +195,17 @@
             self.close_connection = True
             pass
 
+try:
+    from threading import activeCount
+    _mixin = SocketServer.ThreadingMixIn
+except ImportError:
+    if hasattr(os, "fork"):
+        _mixin = SocketServer.ForkingMixIn
+    else:
+        class _mixin:
+            pass
+
 def create_server(ui, repo):
-    use_threads = True
 
     def openlog(opt, default):
         if opt and opt != '-':
@@ -218,21 +227,6 @@
     accesslog = openlog(myui.config("web", "accesslog", "-"), sys.stdout)
     errorlog = openlog(myui.config("web", "errorlog", "-"), sys.stderr)
 
-    if use_threads:
-        try:
-            from threading import activeCount
-        except ImportError:
-            use_threads = False
-
-    if use_threads:
-        _mixin = SocketServer.ThreadingMixIn
-    else:
-        if hasattr(os, "fork"):
-            _mixin = SocketServer.ForkingMixIn
-        else:
-            class _mixin:
-                pass
-
     if webdir_conf:
         hgwebobj = hgwebdir(webdir_conf, ui)
     elif repo is not None: