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

Unified Diff: client/isolate_storage.py

Issue 2968343002: Fix gRPC error handling on Push. (Closed)
Patch Set: Created 3 years, 5 months 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 | no next file » | 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 a119570b71ea423b1c60515e457c414deccec72a..8ce274f5892b1bd68901847720e5d5f7cf18b0e5 100644
--- a/client/isolate_storage.py
+++ b/client/isolate_storage.py
@@ -655,13 +655,11 @@ class IsolateServerGrpc(StorageApi):
request.write_offset += slice_len
chunk = chunk[slice_len:]
+ response = None
try:
response = self._stub.Write(slicer())
- except grpc.Call as c:
- # You might think that errors from gRPC would be rpc.RpcError. You'd
- # be... right... but it's *also* an instance of grpc.Call, and that's
- # where the status code actually lives.
- if c.code() == grpc.StatusCode.ALREADY_EXISTS:
+ except grpc.RpcError as r:
+ if r.code() == grpc.StatusCode.ALREADY_EXISTS:
# This is legit - we didn't check before we pushed so no problem if
# it's already there.
self._already_exists += 1
@@ -670,13 +668,13 @@ class IsolateServerGrpc(StorageApi):
self._already_exists, self._num_pushes,
100.0 * self._already_exists / self._num_pushes))
else:
- logging.error('gRPC error during push: throwing as IOError (%s)' % c)
- raise IOError(c)
+ logging.error('gRPC error during push: throwing as IOError (%s)' % r)
+ raise IOError(r)
except Exception as e:
logging.error('error during push: throwing as IOError (%s)' % e)
raise IOError(e)
- if response.committed_size != item.size:
+ if response is not None and response.committed_size != item.size:
raise IOError('%s/%d: incorrect size written (%d)' % (
item.digest, item.size, response.committed_size))
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698