# HG changeset patch # User Dirkjan Ochtman # Date 1268310519 -3600 # Node ID a6808629f450dfbf20db579382bb595b21015d2a # Parent 92209ae8610af22910848fac895b35095cebf269 server: externalize and streamline mixin setup diff -r 92209ae8610a -r a6808629f450 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: