versioned_writes: stop trying to catch HTTPPreconditionFailed

* We just caught it to raise another one
* On newer versions of python, we wouldn't actually catch
  anything, because HTTPPreconditionFailed is not an instance
  of BaseException -- it's a partial function application
  which when called will return an exception.

Change-Id: Ia44e832e4198e75f3337884c4612f4e9fe3b9e0b
This commit is contained in:
Tim Burke
2019-02-19 13:14:34 -08:00
parent 89b3adc9fb
commit 8e045d0de2

View File

@@ -258,18 +258,16 @@ class VersionedWritesContext(WSGIContext):
def _listing_iter(self, account_name, lcontainer, lprefix, req):
try:
for page in self._listing_pages_iter(account_name, lcontainer,
lprefix, req.environ):
lprefix, req):
for item in page:
yield item
except ListingIterNotFound:
pass
except HTTPPreconditionFailed:
raise HTTPPreconditionFailed(request=req)
except ListingIterError:
raise HTTPServerError(request=req)
def _in_proxy_reverse_listing(self, account_name, lcontainer, lprefix,
env, failed_marker, failed_listing):
req, failed_marker, failed_listing):
'''Get the complete prefix listing and reverse it on the proxy.
This is only necessary if we encounter a response from a
@@ -300,7 +298,7 @@ class VersionedWritesContext(WSGIContext):
try:
for page in self._listing_pages_iter(
account_name, lcontainer, lprefix,
env, marker, end_marker=failed_marker, reverse=False):
req, marker, end_marker=failed_marker, reverse=False):
complete_listing.extend(page)
except ListingIterNotFound:
pass
@@ -310,7 +308,7 @@ class VersionedWritesContext(WSGIContext):
return reversed(complete_listing)
def _listing_pages_iter(self, account_name, lcontainer, lprefix,
env, marker='', end_marker='', reverse=True):
req, marker='', end_marker='', reverse=True):
'''Get "pages" worth of objects that start with a prefix.
The optional keyword arguments ``marker``, ``end_marker``, and
@@ -326,7 +324,7 @@ class VersionedWritesContext(WSGIContext):
'''
while True:
lreq = make_pre_authed_request(
env, method='GET', swift_source='VW',
req.environ, method='GET', swift_source='VW',
path=quote('/v1/%s/%s' % (account_name, lcontainer)))
lreq.environ['QUERY_STRING'] = \
'prefix=%s&marker=%s' % (quote(lprefix), quote(marker))
@@ -341,7 +339,7 @@ class VersionedWritesContext(WSGIContext):
if lresp.status_int == HTTP_NOT_FOUND:
raise ListingIterNotFound()
elif is_client_error(lresp.status_int):
raise HTTPPreconditionFailed()
raise HTTPPreconditionFailed(request=req)
else:
raise ListingIterError()
@@ -361,7 +359,7 @@ class VersionedWritesContext(WSGIContext):
# Apparently there's at least one pre-2.6.0 container server
yield self._in_proxy_reverse_listing(
account_name, lcontainer, lprefix,
env, marker, sublisting)
req, marker, sublisting)
return
marker = last_item