Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(433)

Unified Diff: client/isolate_storage.py

Issue 2599493002: Rethrow Isolate gRPC proxy exceptions as IOError (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | client/tests/isolate_storage_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/isolate_storage.py
diff --git a/client/isolate_storage.py b/client/isolate_storage.py
index d366c551d548bc40bc96e5c075031e2208cd498f..63234b0a1295d85e9e700aa057373ff5516f05be 100644
--- a/client/isolate_storage.py
+++ b/client/isolate_storage.py
@@ -542,17 +542,21 @@ class IsolateServerGrpc(StorageApi):
# array (like [0x01, 0x2a, 0xbc]).
req_digest.digest = binascii.unhexlify(digest)
expected_offset = 0
- for response in self._stub.FetchBlobs(request,
- timeout=DOWNLOAD_READ_TIMEOUT):
- if not response.status.succeeded:
- raise IOError(
- 'Error while fetching %s: %s' % (digest, response.status))
- if not expected_offset == response.data.offset:
- raise IOError(
- 'Error while fetching %s: expected offset %d, got %d' % (
- digest, expected_offset, response.data.offset))
- expected_offset += len(response.data.data)
- yield response.data.data
+ try:
+ for response in self._stub.FetchBlobs(request,
+ timeout=DOWNLOAD_READ_TIMEOUT):
+ if not response.status.succeeded:
+ raise IOError(
+ 'Error while fetching %s: %s' % (digest, response.status))
+ if not expected_offset == response.data.offset:
+ raise IOError(
+ 'Error while fetching %s: expected offset %d, got %d' % (
+ digest, expected_offset, response.data.offset))
+ expected_offset += len(response.data.data)
+ yield response.data.data
+ except grpc.RpcError as g:
+ logging.error('gRPC error during fetch: re-throwing as IOError (%s)' % g)
+ raise IOError(g)
def push(self, item, push_state, content=None):
assert isinstance(item, Item)
@@ -594,7 +598,12 @@ class IsolateServerGrpc(StorageApi):
chunk = chunk[slice_len:]
# TODO(aludwin): batch up several requests to reuse TCP connections
- response = self._stub.PushBlobs(slicer())
+ try:
+ response = self._stub.PushBlobs(slicer())
+ except grpc.RpcError as g:
+ logging.error('gRPC error during push: re-throwing as IOError (%s)' % g)
+ raise IOError(g)
+
if not response.status.succeeded:
raise IOError(
'Error while uploading %s: %s' % (
@@ -614,7 +623,12 @@ class IsolateServerGrpc(StorageApi):
cd = request.digest.add()
cd.digest = binascii.unhexlify(item.digest)
items_by_digest[cd.digest] = item
- response = self._stub.Contains(request)
+ try:
+ response = self._stub.Contains(request)
+ except grpc.RpcError as g:
+ logging.error('gRPC error during contains: re-throwing as IOError (%s)'
+ % g)
+ raise IOError(g)
# If everything's present, return the empty set.
if response.status.succeeded:
« no previous file with comments | « no previous file | client/tests/isolate_storage_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698