commit 545b33f21b1db659f80fd1109469d25ce5ab6533 Author: David Fifield david@bamsoftware.com Date: Thu Jul 28 16:34:16 2011 +0000
Turn "broken pipe" facilitator errors into a one-line log message. --- facilitator.py | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/facilitator.py b/facilitator.py index 287602d..b2f8304 100755 --- a/facilitator.py +++ b/facilitator.py @@ -3,6 +3,7 @@ import BaseHTTPServer import SocketServer import cgi +import errno import getopt import os import re @@ -302,6 +303,19 @@ class Handler(BaseHTTPServer.BaseHTTPRequestHandler): data["relay"] = options.relay_spec self.request.send(urllib.urlencode(data))
+ # Catch "broken pipe" errors that otherwise cause a stack trace in the log. + def catch_epipe(fn): + def ret(self, *args): + try: + fn(self, *args) + except socket.error, e: + if e.errno != errno.EPIPE: + raise + log(u"%s broken pipe" % format_addr(self.client_address)) + return ret + handle = catch_epipe(BaseHTTPServer.BaseHTTPRequestHandler.handle) + finish = catch_epipe(BaseHTTPServer.BaseHTTPRequestHandler.finish) + REGS = RegSet()
opts, args = getopt.gnu_getopt(sys.argv[1:], "dhl:r:",