Stop holding on to sys.exc_info tuples quite so much
This used to be necessary on older eventlet, or you'd get TypeErrors when you went to reraise. Following eventlet 0.13.0, however, it's just extra code. For the original eventlet issue, see https://web.archive.org/web/20140823005223/https://bitbucket.org/eventlet/eventlet/issue/149/yield-in-except-clause-with-wilcard-raise Change-Id: I19ad0968a82827bdd4ef75fde9ed51f193627d6e Related-Bug: 1181146
This commit is contained in:
parent
d97673cf54
commit
7fd5a12872
@ -221,7 +221,7 @@ class InternalClient(object):
|
|||||||
raise UnexpectedResponse(msg, resp)
|
raise UnexpectedResponse(msg, resp)
|
||||||
if exc_type:
|
if exc_type:
|
||||||
# To make pep8 tool happy, in place of raise t, v, tb:
|
# To make pep8 tool happy, in place of raise t, v, tb:
|
||||||
six.reraise(exc_type(*exc_value.args), None, exc_traceback)
|
six.reraise(exc_type, exc_value, exc_traceback)
|
||||||
|
|
||||||
def _get_metadata(
|
def _get_metadata(
|
||||||
self, path, metadata_prefix='', acceptable_statuses=(2,),
|
self, path, metadata_prefix='', acceptable_statuses=(2,),
|
||||||
|
@ -71,10 +71,8 @@ if this is a middleware subrequest or not. A log processor calculating
|
|||||||
bandwidth usage will want to only sum up logs with no swift.source.
|
bandwidth usage will want to only sum up logs with no swift.source.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sys
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import six
|
|
||||||
from six.moves.urllib.parse import quote
|
from six.moves.urllib.parse import quote
|
||||||
from swift.common.swob import Request
|
from swift.common.swob import Request
|
||||||
from swift.common.utils import (get_logger, get_remote_client,
|
from swift.common.utils import (get_logger, get_remote_client,
|
||||||
@ -333,13 +331,12 @@ class ProxyLoggingMiddleware(object):
|
|||||||
try:
|
try:
|
||||||
iterable = self.app(env, my_start_response)
|
iterable = self.app(env, my_start_response)
|
||||||
except Exception:
|
except Exception:
|
||||||
exc_type, exc_value, exc_traceback = sys.exc_info()
|
|
||||||
req = Request(env)
|
req = Request(env)
|
||||||
status_int = status_int_for_logging(start_status=500)
|
status_int = status_int_for_logging(start_status=500)
|
||||||
self.log_request(
|
self.log_request(
|
||||||
req, status_int, input_proxy.bytes_received, 0, start_time,
|
req, status_int, input_proxy.bytes_received, 0, start_time,
|
||||||
time.time())
|
time.time())
|
||||||
six.reraise(exc_type, exc_value, exc_traceback)
|
raise
|
||||||
else:
|
else:
|
||||||
return iter_response(iterable)
|
return iter_response(iterable)
|
||||||
|
|
||||||
|
@ -49,8 +49,6 @@ Example::
|
|||||||
the end of method.
|
the end of method.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import sys
|
|
||||||
|
|
||||||
from swift.common.middleware.s3api.subresource import ACL, Owner, encode_acl
|
from swift.common.middleware.s3api.subresource import ACL, Owner, encode_acl
|
||||||
from swift.common.middleware.s3api.s3response import MissingSecurityHeader, \
|
from swift.common.middleware.s3api.s3response import MissingSecurityHeader, \
|
||||||
MalformedACLError, UnexpectedContent
|
MalformedACLError, UnexpectedContent
|
||||||
@ -168,9 +166,8 @@ class BaseAclHandler(object):
|
|||||||
except(XMLSyntaxError, DocumentInvalid):
|
except(XMLSyntaxError, DocumentInvalid):
|
||||||
raise MalformedACLError()
|
raise MalformedACLError()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
exc_type, exc_value, exc_traceback = sys.exc_info()
|
|
||||||
self.logger.error(e)
|
self.logger.error(e)
|
||||||
raise exc_type, exc_value, exc_traceback
|
raise
|
||||||
else:
|
else:
|
||||||
if body:
|
if body:
|
||||||
# Specifying grant with both header and xml is not allowed.
|
# Specifying grant with both header and xml is not allowed.
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import sys
|
|
||||||
from base64 import standard_b64encode as b64encode
|
from base64 import standard_b64encode as b64encode
|
||||||
from base64 import standard_b64decode as b64decode
|
from base64 import standard_b64decode as b64decode
|
||||||
|
|
||||||
@ -218,9 +217,8 @@ class BucketController(Controller):
|
|||||||
except (XMLSyntaxError, DocumentInvalid):
|
except (XMLSyntaxError, DocumentInvalid):
|
||||||
raise MalformedXML()
|
raise MalformedXML()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
exc_type, exc_value, exc_traceback = sys.exc_info()
|
|
||||||
self.logger.error(e)
|
self.logger.error(e)
|
||||||
raise exc_type, exc_value, exc_traceback
|
raise
|
||||||
|
|
||||||
if location != self.conf.location:
|
if location != self.conf.location:
|
||||||
# s3api cannot support multiple regions currently.
|
# s3api cannot support multiple regions currently.
|
||||||
|
@ -13,8 +13,6 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
from swift.common.utils import public
|
from swift.common.utils import public
|
||||||
|
|
||||||
from swift.common.middleware.s3api.controllers.base import Controller, \
|
from swift.common.middleware.s3api.controllers.base import Controller, \
|
||||||
@ -85,9 +83,8 @@ class MultiObjectDeleteController(Controller):
|
|||||||
except ErrorResponse:
|
except ErrorResponse:
|
||||||
raise
|
raise
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
exc_type, exc_value, exc_traceback = sys.exc_info()
|
|
||||||
self.logger.error(e)
|
self.logger.error(e)
|
||||||
raise exc_type, exc_value, exc_traceback
|
raise
|
||||||
|
|
||||||
elem = Element('DeleteResult')
|
elem = Element('DeleteResult')
|
||||||
|
|
||||||
|
@ -61,7 +61,6 @@ Static Large Object when the multipart upload is completed.
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
|
||||||
|
|
||||||
from swift.common.swob import Range
|
from swift.common.swob import Range
|
||||||
from swift.common.utils import json, public
|
from swift.common.utils import json, public
|
||||||
@ -605,9 +604,8 @@ class UploadController(Controller):
|
|||||||
except ErrorResponse:
|
except ErrorResponse:
|
||||||
raise
|
raise
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
exc_type, exc_value, exc_traceback = sys.exc_info()
|
|
||||||
self.logger.error(e)
|
self.logger.error(e)
|
||||||
raise exc_type, exc_value, exc_traceback
|
raise
|
||||||
|
|
||||||
# Check the size of each segment except the last and make sure they are
|
# Check the size of each segment except the last and make sure they are
|
||||||
# all more than the minimum upload chunk size
|
# all more than the minimum upload chunk size
|
||||||
|
@ -13,8 +13,6 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
from swift.common.http import HTTP_OK, HTTP_PARTIAL_CONTENT, HTTP_NO_CONTENT
|
from swift.common.http import HTTP_OK, HTTP_PARTIAL_CONTENT, HTTP_NO_CONTENT
|
||||||
from swift.common.swob import Range, content_range_header_value
|
from swift.common.swob import Range, content_range_header_value
|
||||||
from swift.common.utils import public
|
from swift.common.utils import public
|
||||||
@ -144,7 +142,6 @@ class ObjectController(Controller):
|
|||||||
resp.body = ''
|
resp.body = ''
|
||||||
except NoSuchKey:
|
except NoSuchKey:
|
||||||
# expect to raise NoSuchBucket when the bucket doesn't exist
|
# expect to raise NoSuchBucket when the bucket doesn't exist
|
||||||
exc_type, exc_value, exc_traceback = sys.exc_info()
|
|
||||||
req.get_container_info(self.app)
|
req.get_container_info(self.app)
|
||||||
raise exc_type, exc_value, exc_traceback
|
raise
|
||||||
return resp
|
return resp
|
||||||
|
@ -18,7 +18,6 @@ from urllib import quote
|
|||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from pkg_resources import resource_stream # pylint: disable-msg=E0611
|
from pkg_resources import resource_stream # pylint: disable-msg=E0611
|
||||||
import six
|
import six
|
||||||
import sys
|
|
||||||
|
|
||||||
from swift.common.utils import get_logger
|
from swift.common.utils import get_logger
|
||||||
from swift.common.middleware.s3api.exception import S3Exception
|
from swift.common.middleware.s3api.exception import S3Exception
|
||||||
@ -76,10 +75,9 @@ def fromstring(text, root_tag=None, logger=None):
|
|||||||
lxml.etree.RelaxNG(file=rng).assertValid(elem)
|
lxml.etree.RelaxNG(file=rng).assertValid(elem)
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
# Probably, the schema file doesn't exist.
|
# Probably, the schema file doesn't exist.
|
||||||
exc_type, exc_value, exc_traceback = sys.exc_info()
|
|
||||||
logger = logger or get_logger({}, log_route='s3api')
|
logger = logger or get_logger({}, log_route='s3api')
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
raise exc_type, exc_value, exc_traceback
|
raise
|
||||||
except lxml.etree.DocumentInvalid as e:
|
except lxml.etree.DocumentInvalid as e:
|
||||||
if logger:
|
if logger:
|
||||||
logger.debug(e)
|
logger.debug(e)
|
||||||
|
@ -973,7 +973,7 @@ class ResumingGetter(object):
|
|||||||
except ChunkReadTimeout:
|
except ChunkReadTimeout:
|
||||||
exc_type, exc_value, exc_traceback = exc_info()
|
exc_type, exc_value, exc_traceback = exc_info()
|
||||||
if self.newest or self.server_type != 'Object':
|
if self.newest or self.server_type != 'Object':
|
||||||
six.reraise(exc_type, exc_value, exc_traceback)
|
raise
|
||||||
try:
|
try:
|
||||||
self.fast_forward(self.bytes_used_from_backend)
|
self.fast_forward(self.bytes_used_from_backend)
|
||||||
except (HTTPException, ValueError):
|
except (HTTPException, ValueError):
|
||||||
@ -1091,20 +1091,18 @@ class ResumingGetter(object):
|
|||||||
self.app.client_timeout)
|
self.app.client_timeout)
|
||||||
self.app.logger.increment('client_timeouts')
|
self.app.logger.increment('client_timeouts')
|
||||||
except GeneratorExit:
|
except GeneratorExit:
|
||||||
exc_type, exc_value, exc_traceback = exc_info()
|
|
||||||
warn = True
|
warn = True
|
||||||
try:
|
req_range = self.backend_headers['Range']
|
||||||
req_range = Range(self.backend_headers['Range'])
|
if req_range:
|
||||||
except ValueError:
|
req_range = Range(req_range)
|
||||||
req_range = None
|
if len(req_range.ranges) == 1:
|
||||||
if req_range and len(req_range.ranges) == 1:
|
begin, end = req_range.ranges[0]
|
||||||
begin, end = req_range.ranges[0]
|
if end is not None and begin is not None:
|
||||||
if end is not None and begin is not None:
|
if end - begin + 1 == self.bytes_used_from_backend:
|
||||||
if end - begin + 1 == self.bytes_used_from_backend:
|
warn = False
|
||||||
warn = False
|
|
||||||
if not req.environ.get('swift.non_client_disconnect') and warn:
|
if not req.environ.get('swift.non_client_disconnect') and warn:
|
||||||
self.app.logger.warning(_('Client disconnected on read'))
|
self.app.logger.warning(_('Client disconnected on read'))
|
||||||
six.reraise(exc_type, exc_value, exc_traceback)
|
raise
|
||||||
except Exception:
|
except Exception:
|
||||||
self.app.logger.exception(_('Trying to send to client'))
|
self.app.logger.exception(_('Trying to send to client'))
|
||||||
raise
|
raise
|
||||||
|
Loading…
Reference in New Issue
Block a user