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

login
register
mail settings
Submitter Mads Kiilerich
Date Oct. 10, 2013, 2:35 a.m.
Message ID <0143b6956677af12c3bd.1381372551@mk-desktop>
Download mbox | patch
Permalink /patch/2741/
State Superseded, archived
Headers show

Comments

Mads Kiilerich - Oct. 10, 2013, 2:35 a.m.
# HG changeset patch
# User Mads Kiilerich <madski@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.

Patch

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],