示例#1
0
文件: _server.py 项目: tick90011/grpc
def _stream_response_in_pool(rpc_event, state, behavior, argument_thunk,
                             request_deserializer, response_serializer):
    cygrpc.install_context_from_call(rpc_event.call)

    def send_response(response):
        if response is None:
            _status(rpc_event, state, None)
        else:
            serialized_response = _serialize_response(rpc_event, state,
                                                      response,
                                                      response_serializer)
            if serialized_response is not None:
                _send_response(rpc_event, state, serialized_response)

    try:
        argument = argument_thunk()
        if argument is not None:
            if hasattr(behavior, 'experimental_non_blocking'
                       ) and behavior.experimental_non_blocking:
                _call_behavior(rpc_event,
                               state,
                               behavior,
                               argument,
                               request_deserializer,
                               send_response_callback=send_response)
            else:
                response_iterator, proceed = _call_behavior(
                    rpc_event, state, behavior, argument, request_deserializer)
                if proceed:
                    _send_message_callback_to_blocking_iterator_adapter(
                        rpc_event, state, send_response, response_iterator)
    finally:
        cygrpc.uninstall_context()
示例#2
0
def _stream_response_in_pool(rpc_event, state, behavior, argument_thunk,
                             request_deserializer, response_serializer):
    cygrpc.install_context_from_call(rpc_event.call)
    try:
        argument = argument_thunk()
        if argument is not None:
            response_iterator, proceed = _call_behavior(
                rpc_event, state, behavior, argument, request_deserializer)
            if proceed:
                while True:
                    response, proceed = _take_response_from_response_iterator(
                        rpc_event, state, response_iterator)
                    if proceed:
                        if response is None:
                            _status(rpc_event, state, None)
                            break
                        else:
                            serialized_response = _serialize_response(
                                rpc_event, state, response, response_serializer)
                            if serialized_response is not None:
                                proceed = _send_response(
                                    rpc_event, state, serialized_response)
                                if not proceed:
                                    break
                            else:
                                break
                    else:
                        break
    finally:
        cygrpc.uninstall_context()
示例#3
0
def _stream_response_in_pool(rpc_event, state, behavior, argument_thunk,
                             request_deserializer, response_serializer):
    cygrpc.install_context_from_call(rpc_event.call)
    try:
        argument = argument_thunk()
        if argument is not None:
            response_iterator, proceed = _call_behavior(
                rpc_event, state, behavior, argument, request_deserializer)
            if proceed:
                while True:
                    response, proceed = _take_response_from_response_iterator(
                        rpc_event, state, response_iterator)
                    if proceed:
                        if response is None:
                            _status(rpc_event, state, None)
                            break
                        else:
                            serialized_response = _serialize_response(
                                rpc_event, state, response,
                                response_serializer)
                            if serialized_response is not None:
                                proceed = _send_response(
                                    rpc_event, state, serialized_response)
                                if not proceed:
                                    break
                            else:
                                break
                    else:
                        break
    finally:
        cygrpc.uninstall_context()
示例#4
0
文件: _server.py 项目: tick90011/grpc
def _unary_response_in_pool(rpc_event, state, behavior, argument_thunk,
                            request_deserializer, response_serializer):
    cygrpc.install_context_from_call(rpc_event.call)
    try:
        argument = argument_thunk()
        if argument is not None:
            response, proceed = _call_behavior(rpc_event, state, behavior,
                                               argument, request_deserializer)
            if proceed:
                serialized_response = _serialize_response(
                    rpc_event, state, response, response_serializer)
                if serialized_response is not None:
                    _status(rpc_event, state, serialized_response)
    finally:
        cygrpc.uninstall_context()
示例#5
0
def _unary_response_in_pool(rpc_event, state, behavior, argument_thunk,
                            request_deserializer, response_serializer):
    cygrpc.install_context_from_call(rpc_event.call)
    try:
        argument = argument_thunk()
        if argument is not None:
            response, proceed = _call_behavior(rpc_event, state, behavior,
                                               argument, request_deserializer)
            if proceed:
                serialized_response = _serialize_response(
                    rpc_event, state, response, response_serializer)
                if serialized_response is not None:
                    _status(rpc_event, state, serialized_response)
    finally:
        cygrpc.uninstall_context()