From 5df49b5a38410f13e24ee7b20458407a063ebb3e Mon Sep 17 00:00:00 2001 From: Neil Williams Date: Sat, 7 Apr 2012 18:56:51 -0700 Subject: [PATCH] Don't put ops-related exceptions in log_q. They're transient situations outside the app's domain and not bugs. (though they probably do indicate a place where we should be more robust, so don't ignore them entirely.) --- r2/r2/lib/base.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/r2/r2/lib/base.py b/r2/r2/lib/base.py index a45ddc5ae..82930f9b1 100644 --- a/r2/r2/lib/base.py +++ b/r2/r2/lib/base.py @@ -20,6 +20,10 @@ # CondeNet, Inc. All Rights Reserved. ################################################################################ +import _pylibmc +import pycassa.pool +import sqlalchemy.exc + from pylons import Response, c, g, request, session, config from pylons.controllers import WSGIController, Controller from pylons.controllers.util import abort @@ -30,6 +34,7 @@ from r2.lib.filters import spaceCompress, _force_unicode from r2.lib.template_helpers import get_domain from utils import storify, string2js, read_http_date from r2.lib.log import log_exception +import r2.lib.db.thing import re, hashlib from urllib import quote @@ -37,6 +42,16 @@ import urllib2 import sys +OPERATIONAL_EXCEPTIONS = (_pylibmc.MemcachedError, + r2.lib.db.thing.NotFound, + sqlalchemy.exc.OperationalError, + sqlalchemy.exc.IntegrityError, + pycassa.pool.AllServersUnavailable, + pycassa.pool.NoConnectionAvailable, + pycassa.pool.MaximumRetryException, + ) + + #TODO hack import logging from r2.lib.utils import UrlParser, query_string @@ -113,7 +128,7 @@ class BaseController(WSGIController): try: res = WSGIController.__call__(self, environ, start_response) except Exception as e: - if g.exception_logging: + if g.exception_logging and not isinstance(e, OPERATIONAL_EXCEPTIONS): try: log_exception(e, *sys.exc_info()) except Exception as f: