[PATCH 3 of 5 RFC] serve: mute 'connection closed' exceptions

Mads Kiilerich mads at kiilerich.com
Wed Oct 9 21:35:51 CDT 2013


# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1381367773 -7200
#      Thu Oct 10 03:16:13 2013 +0200
# Node ID 0143b6956677af12c3bd51f41ff4a26a31c2e367
# Parent  287245cf5fa1264f19664704994dbfd9c38cfdff
serve: mute 'connection closed' exceptions

'hg serve' in combination with authentication would for some reason give
exceptions because connections are closed. This change will mute these
exceptions. It might just be a workaround for a real problem somewhere.

diff --git a/mercurial/hgweb/server.py b/mercurial/hgweb/server.py
--- a/mercurial/hgweb/server.py
+++ b/mercurial/hgweb/server.py
@@ -45,7 +45,13 @@
 
     def __init__(self, *args, **kargs):
         self.protocol_version = 'HTTP/1.1'
-        BaseHTTPServer.BaseHTTPRequestHandler.__init__(self, *args, **kargs)
+        try:
+            BaseHTTPServer.BaseHTTPRequestHandler.__init__(self,
+                                                           *args, **kargs)
+        except BaseHTTPServer.socket.error, e:
+            if e.errno != errno.ECONNRESET:
+                raise
+            # happens all the time when using authentication ...
 
     def _log_any(self, fp, format, *args):
         fp.write("%s - - [%s] %s\n" % (self.client_address[0],


More information about the Mercurial-devel mailing list