changeset 10639:a6808629f450

server: externalize and streamline mixin setup
author Dirkjan Ochtman <djc.ochtman@kentyde.com>
date Thu, 11 Mar 2010 13:28:39 +0100
parents 92209ae8610a
children 90a095c24bc4
files mercurial/hgweb/server.py
diffstat 1 files changed, 10 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- 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: