diff --git a/swift/common/utils.py b/swift/common/utils.py index 53c62548b4..06c9ded308 100644 --- a/swift/common/utils.py +++ b/swift/common/utils.py @@ -71,7 +71,10 @@ import codecs utf8_decoder = codecs.getdecoder('utf-8') utf8_encoder = codecs.getencoder('utf-8') import six -if not six.PY2: +if six.PY2: + from eventlet.green import httplib as green_http_client +else: + from eventlet.green.http import client as green_http_client utf16_decoder = codecs.getdecoder('utf-16') utf16_encoder = codecs.getencoder('utf-16') from six.moves import cPickle as pickle @@ -2242,7 +2245,8 @@ class LogAdapter(logging.LoggerAdapter, object): emsg = _('Broken pipe') else: call = self._exception - elif isinstance(exc, http_client.BadStatusLine): + 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): diff --git a/test/unit/common/test_utils.py b/test/unit/common/test_utils.py index 2893c2bac8..bb9e31eb35 100644 --- a/test/unit/common/test_utils.py +++ b/test/unit/common/test_utils.py @@ -84,6 +84,11 @@ from swift.common.swob import Request, Response from test.unit import requires_o_tmpfile_support_in_tmp, \ quiet_eventlet_exceptions +if six.PY2: + import eventlet.green.httplib as green_http_client +else: + import eventlet.green.http.client as green_http_client + threading = eventlet.patcher.original('threading') @@ -1989,6 +1994,13 @@ class TestUtils(unittest.TestCase): self.assertIn('BadStatusLine', log_msg) self.assertIn("''", 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) + # test unhandled log_exception(Exception('my error message')) log_msg = strip_value(sio)