|
|
@ -100,7 +100,7 @@ class _RPCState(object): |
|
|
|
self.statused = False |
|
|
|
self.statused = False |
|
|
|
self.rpc_errors = [] |
|
|
|
self.rpc_errors = [] |
|
|
|
self.callbacks = [] |
|
|
|
self.callbacks = [] |
|
|
|
self.abortion = None |
|
|
|
self.aborted = False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _raise_rpc_error(state): |
|
|
|
def _raise_rpc_error(state): |
|
|
@ -287,8 +287,8 @@ class _Context(grpc.ServicerContext): |
|
|
|
with self._state.condition: |
|
|
|
with self._state.condition: |
|
|
|
self._state.code = code |
|
|
|
self._state.code = code |
|
|
|
self._state.details = _common.encode(details) |
|
|
|
self._state.details = _common.encode(details) |
|
|
|
self._state.abortion = Exception() |
|
|
|
self._state.aborted = True |
|
|
|
raise self._state.abortion |
|
|
|
raise Exception() |
|
|
|
|
|
|
|
|
|
|
|
def abort_with_status(self, status): |
|
|
|
def abort_with_status(self, status): |
|
|
|
self._state.trailing_metadata = status.trailing_metadata |
|
|
|
self._state.trailing_metadata = status.trailing_metadata |
|
|
@ -392,7 +392,7 @@ def _call_behavior(rpc_event, state, behavior, argument, request_deserializer): |
|
|
|
return behavior(argument, context), True |
|
|
|
return behavior(argument, context), True |
|
|
|
except Exception as exception: # pylint: disable=broad-except |
|
|
|
except Exception as exception: # pylint: disable=broad-except |
|
|
|
with state.condition: |
|
|
|
with state.condition: |
|
|
|
if exception is state.abortion: |
|
|
|
if state.aborted: |
|
|
|
_abort(state, rpc_event.call, cygrpc.StatusCode.unknown, |
|
|
|
_abort(state, rpc_event.call, cygrpc.StatusCode.unknown, |
|
|
|
b'RPC Aborted') |
|
|
|
b'RPC Aborted') |
|
|
|
elif exception not in state.rpc_errors: |
|
|
|
elif exception not in state.rpc_errors: |
|
|
@ -410,7 +410,7 @@ def _take_response_from_response_iterator(rpc_event, state, response_iterator): |
|
|
|
return None, True |
|
|
|
return None, True |
|
|
|
except Exception as exception: # pylint: disable=broad-except |
|
|
|
except Exception as exception: # pylint: disable=broad-except |
|
|
|
with state.condition: |
|
|
|
with state.condition: |
|
|
|
if exception is state.abortion: |
|
|
|
if state.aborted: |
|
|
|
_abort(state, rpc_event.call, cygrpc.StatusCode.unknown, |
|
|
|
_abort(state, rpc_event.call, cygrpc.StatusCode.unknown, |
|
|
|
b'RPC Aborted') |
|
|
|
b'RPC Aborted') |
|
|
|
elif exception not in state.rpc_errors: |
|
|
|
elif exception not in state.rpc_errors: |
|
|
|