Patchwork [2,of,4] py3: conditionalize access to socketserver.ForkingMixIn

login
register
mail settings
Submitter Matt Harbison
Date Sept. 26, 2018, 4:06 a.m.
Message ID <b5d88137328115c98cde.1537934762@Envy>
Download mbox | patch
Permalink /patch/35040/
State Accepted
Headers show

Comments

Matt Harbison - Sept. 26, 2018, 4:06 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1537925982 14400
#      Tue Sep 25 21:39:42 2018 -0400
# Node ID b5d88137328115c98cdec6ae3902b6128823368d
# Parent  9403d51284f4cab9b143612157c747fe13382c5b
py3: conditionalize access to socketserver.ForkingMixIn

This is no longer exported on platforms that don't support forking, as of 3.6.

https://github.com/python/cpython/commit/aadff9bea61a2fc9f4cf0f213f0ee50fc54d6574

Patch

diff --git a/mercurial/hgweb/server.py b/mercurial/hgweb/server.py
--- a/mercurial/hgweb/server.py
+++ b/mercurial/hgweb/server.py
@@ -174,8 +174,12 @@  class _httprequesthandler(httpservermod.
         env[r'wsgi.errors'] = _error_logger(self)
         env[r'wsgi.multithread'] = isinstance(self.server,
                                              socketserver.ThreadingMixIn)
-        env[r'wsgi.multiprocess'] = isinstance(self.server,
-                                              socketserver.ForkingMixIn)
+        if util.safehasattr(socketserver, 'ForkingMixIn'):
+            env[r'wsgi.multiprocess'] = isinstance(self.server,
+                                                   socketserver.ForkingMixIn)
+        else:
+            env[r'wsgi.multiprocess'] = False
+
         env[r'wsgi.run_once'] = 0
 
         wsgiref.validate.check_environ(env)