Merge "py3: Quiet RemoteDisconnected tracebacks"
This commit is contained in:
commit
7b1f7ee857
@ -1600,7 +1600,14 @@ class LogAdapter(logging.LoggerAdapter, object):
|
||||
_junk, exc, _junk = sys.exc_info()
|
||||
call = self.error
|
||||
emsg = ''
|
||||
if isinstance(exc, (OSError, socket.error)):
|
||||
if isinstance(exc, (http_client.BadStatusLine,
|
||||
green_http_client.BadStatusLine)):
|
||||
# Use error(); not really exceptional
|
||||
emsg = repr(exc)
|
||||
# Note that on py3, we've seen a RemoteDisconnected error getting
|
||||
# raised, which inherits from *both* BadStatusLine and OSError;
|
||||
# we want it getting caught here
|
||||
elif isinstance(exc, (OSError, socket.error)):
|
||||
if exc.errno in (errno.EIO, errno.ENOSPC):
|
||||
emsg = str(exc)
|
||||
elif exc.errno == errno.ECONNREFUSED:
|
||||
@ -1617,10 +1624,6 @@ class LogAdapter(logging.LoggerAdapter, object):
|
||||
emsg = 'Broken pipe'
|
||||
else:
|
||||
call = self._exception
|
||||
elif isinstance(exc, (http_client.BadStatusLine,
|
||||
green_http_client.BadStatusLine)):
|
||||
# Use error(); not really exceptional
|
||||
emsg = '%s: %s' % (exc.__class__.__name__, exc.line)
|
||||
elif isinstance(exc, eventlet.Timeout):
|
||||
emsg = exc.__class__.__name__
|
||||
detail = '%ss' % exc.seconds
|
||||
|
@ -1221,15 +1221,33 @@ class TestUtils(unittest.TestCase):
|
||||
log_exception(http_client.BadStatusLine(''))
|
||||
log_msg = strip_value(sio)
|
||||
self.assertNotIn('Traceback', log_msg)
|
||||
self.assertIn('BadStatusLine', log_msg)
|
||||
self.assertIn("''", log_msg)
|
||||
self.assertIn('''BadStatusLine("''"''', log_msg)
|
||||
|
||||
# green version is separate :-(
|
||||
log_exception(green_http_client.BadStatusLine(''))
|
||||
log_msg = strip_value(sio)
|
||||
self.assertNotIn('Traceback', log_msg)
|
||||
self.assertIn('BadStatusLine', log_msg)
|
||||
self.assertIn("''", log_msg)
|
||||
self.assertIn('''BadStatusLine("''"''', log_msg)
|
||||
|
||||
if not six.PY2:
|
||||
# py3 introduced RemoteDisconnected exceptions which inherit
|
||||
# from both BadStatusLine *and* OSError; make sure those are
|
||||
# handled as BadStatusLine, not OSError
|
||||
log_exception(http_client.RemoteDisconnected(
|
||||
'Remote end closed connection'))
|
||||
log_msg = strip_value(sio)
|
||||
self.assertNotIn('Traceback', log_msg)
|
||||
self.assertIn(
|
||||
"RemoteDisconnected('Remote end closed connection'",
|
||||
log_msg)
|
||||
|
||||
log_exception(green_http_client.RemoteDisconnected(
|
||||
'Remote end closed connection'))
|
||||
log_msg = strip_value(sio)
|
||||
self.assertNotIn('Traceback', log_msg)
|
||||
self.assertIn(
|
||||
"RemoteDisconnected('Remote end closed connection'",
|
||||
log_msg)
|
||||
|
||||
# test unhandled
|
||||
log_exception(Exception('my error message'))
|
||||
|
Loading…
Reference in New Issue
Block a user