|
|
@ -302,6 +302,9 @@ class _Context(grpc.ServicerContext): |
|
|
|
with self._state.condition: |
|
|
|
with self._state.condition: |
|
|
|
self._state.details = _common.encode(details) |
|
|
|
self._state.details = _common.encode(details) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _finalize_state(self): |
|
|
|
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _RequestIterator(object): |
|
|
|
class _RequestIterator(object): |
|
|
|
|
|
|
|
|
|
|
@ -387,20 +390,24 @@ def _unary_request(rpc_event, state, request_deserializer): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _call_behavior(rpc_event, state, behavior, argument, request_deserializer): |
|
|
|
def _call_behavior(rpc_event, state, behavior, argument, request_deserializer): |
|
|
|
context = _Context(rpc_event, state, request_deserializer) |
|
|
|
from grpc import _create_servicer_context |
|
|
|
try: |
|
|
|
with _create_servicer_context(rpc_event, state, |
|
|
|
return behavior(argument, context), True |
|
|
|
request_deserializer) as context: |
|
|
|
except Exception as exception: # pylint: disable=broad-except |
|
|
|
try: |
|
|
|
with state.condition: |
|
|
|
response = behavior(argument, context) |
|
|
|
if state.aborted: |
|
|
|
return response, True |
|
|
|
_abort(state, rpc_event.call, cygrpc.StatusCode.unknown, |
|
|
|
except Exception as exception: # pylint: disable=broad-except |
|
|
|
b'RPC Aborted') |
|
|
|
with state.condition: |
|
|
|
elif exception not in state.rpc_errors: |
|
|
|
if state.aborted: |
|
|
|
details = 'Exception calling application: {}'.format(exception) |
|
|
|
_abort(state, rpc_event.call, cygrpc.StatusCode.unknown, |
|
|
|
_LOGGER.exception(details) |
|
|
|
b'RPC Aborted') |
|
|
|
_abort(state, rpc_event.call, cygrpc.StatusCode.unknown, |
|
|
|
elif exception not in state.rpc_errors: |
|
|
|
_common.encode(details)) |
|
|
|
details = 'Exception calling application: {}'.format( |
|
|
|
return None, False |
|
|
|
exception) |
|
|
|
|
|
|
|
_LOGGER.exception(details) |
|
|
|
|
|
|
|
_abort(state, rpc_event.call, cygrpc.StatusCode.unknown, |
|
|
|
|
|
|
|
_common.encode(details)) |
|
|
|
|
|
|
|
return None, False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _take_response_from_response_iterator(rpc_event, state, response_iterator): |
|
|
|
def _take_response_from_response_iterator(rpc_event, state, response_iterator): |
|
|
|