Skip to content
Snippets Groups Projects
Commit e39edac2 authored by Ken Payson's avatar Ken Payson
Browse files

Fixed name syntax error

parent 7c467547
No related branches found
No related tags found
No related merge requests found
...@@ -353,12 +353,12 @@ class _Rendezvous(grpc.RpcError, grpc.Future, grpc.Call): ...@@ -353,12 +353,12 @@ class _Rendezvous(grpc.RpcError, grpc.Future, grpc.Call):
else: else:
return max(self._deadline - time.time(), 0) return max(self._deadline - time.time(), 0)
def add_cancellation_callback(self, callback): def add_callback(self, callback):
with self._state.condition: with self._state.condition:
if self._state.callbacks is None: if self._state.callbacks is None:
return False return False
else: else:
self._state.callbacks.append(lambda unused_future: callback()) self._state.callbacks.append(lambda: callback())
return True return True
def initial_metadata(self): def initial_metadata(self):
......
...@@ -67,7 +67,7 @@ def _abortion(rpc_error_call): ...@@ -67,7 +67,7 @@ def _abortion(rpc_error_call):
error_kind = face.Abortion.Kind.LOCAL_FAILURE if pair is None else pair[0] error_kind = face.Abortion.Kind.LOCAL_FAILURE if pair is None else pair[0]
return face.Abortion( return face.Abortion(
error_kind, rpc_error_call.initial_metadata(), error_kind, rpc_error_call.initial_metadata(),
rpc_error_call.trailing_metadata(), code, rpc_error_code.details()) rpc_error_call.trailing_metadata(), code, rpc_error_call.details())
def _abortion_error(rpc_error_call): def _abortion_error(rpc_error_call):
...@@ -159,9 +159,11 @@ class _Rendezvous(future.Future, face.Call): ...@@ -159,9 +159,11 @@ class _Rendezvous(future.Future, face.Call):
return self._call.time_remaining() return self._call.time_remaining()
def add_abortion_callback(self, abortion_callback): def add_abortion_callback(self, abortion_callback):
registered = self._call.add_callback( def done_callback():
lambda: abortion_callback(_abortion(self._call))) if self.code() is not grpc.StatusCode.OK:
return None if registered else _abortion(self._call) abortion_callback(_abortion(self._call))
registered = self._call.add_callback(done_callback)
return None if registered else done_callback()
def protocol_context(self): def protocol_context(self):
return _InvocationProtocolContext() return _InvocationProtocolContext()
......
...@@ -434,11 +434,13 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest. ...@@ -434,11 +434,13 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
callback = _Callback() callback = _Callback()
abortion_callback = _Callback()
with self._control.fail(): with self._control.fail():
response_future = self._invoker.future(group, method)( response_future = self._invoker.future(group, method)(
request, _3069_test_constant.REALLY_SHORT_TIMEOUT) request, _3069_test_constant.REALLY_SHORT_TIMEOUT)
response_future.add_done_callback(callback) response_future.add_done_callback(callback)
response_future.add_abortion_callback(abortion_callback)
self.assertIs(callback.future(), response_future) self.assertIs(callback.future(), response_future)
# Because the servicer fails outside of the thread from which the # Because the servicer fails outside of the thread from which the
...@@ -450,6 +452,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest. ...@@ -450,6 +452,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
with self.assertRaises(face.ExpirationError): with self.assertRaises(face.ExpirationError):
response_future.result() response_future.result()
self.assertIsNotNone(response_future.traceback()) self.assertIsNotNone(response_future.traceback())
self.assertIsNotNone(abortion_callback.future())
def testFailedUnaryRequestStreamResponse(self): def testFailedUnaryRequestStreamResponse(self):
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
...@@ -472,11 +475,13 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest. ...@@ -472,11 +475,13 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()
callback = _Callback() callback = _Callback()
abortion_callback = _Callback()
with self._control.fail(): with self._control.fail():
response_future = self._invoker.future(group, method)( response_future = self._invoker.future(group, method)(
iter(requests), _3069_test_constant.REALLY_SHORT_TIMEOUT) iter(requests), _3069_test_constant.REALLY_SHORT_TIMEOUT)
response_future.add_done_callback(callback) response_future.add_done_callback(callback)
response_future.add_abortion_callback(abortion_callback)
self.assertIs(callback.future(), response_future) self.assertIs(callback.future(), response_future)
# Because the servicer fails outside of the thread from which the # Because the servicer fails outside of the thread from which the
...@@ -488,6 +493,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest. ...@@ -488,6 +493,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
with self.assertRaises(face.ExpirationError): with self.assertRaises(face.ExpirationError):
response_future.result() response_future.result()
self.assertIsNotNone(response_future.traceback()) self.assertIsNotNone(response_future.traceback())
self.assertIsNotNone(abortion_callback.future())
def testFailedStreamRequestStreamResponse(self): def testFailedStreamRequestStreamResponse(self):
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment