コード例 #1
0
ファイル: _call.py プロジェクト: Mingyu-Liang/grpc
def _create_rpc_error(initial_metadata: Optional[MetadataType],
                      status: cygrpc.AioRpcStatus) -> AioRpcError:
    return AioRpcError(
        _common.CYGRPC_STATUS_CODE_TO_STATUS_CODE[status.code()],
        status.details(),
        initial_metadata,
        status.trailing_metadata(),
        status.debug_error_string(),
    )
コード例 #2
0
ファイル: _call.py プロジェクト: Kvnyu/culie
def _create_rpc_error(initial_metadata: Metadata,
                      status: cygrpc.AioRpcStatus) -> AioRpcError:
    return AioRpcError(
        _common.CYGRPC_STATUS_CODE_TO_STATUS_CODE[status.code()],
        Metadata.from_tuple(initial_metadata),
        Metadata.from_tuple(status.trailing_metadata()),
        details=status.details(),
        debug_error_string=status.debug_error_string(),
    )
コード例 #3
0
    def _set_status(self, status: cygrpc.AioRpcStatus) -> None:
        """Private method to set final status of the RPC.

        This method may be called multiple time due to data race between local
        cancellation (by application) and Core receiving status from peer. We
        make no promise here which one will win.
        """
        if self._status.done():
            return
        else:
            self._status.set_result(status)
            self._code = _common.CYGRPC_STATUS_CODE_TO_STATUS_CODE[
                status.code()]
コード例 #4
0
ファイル: _call.py プロジェクト: sunhuiyong/grpc
    def _set_status(self, status: cygrpc.AioRpcStatus) -> None:
        """Private method to set final status of the RPC.

        This method may be called multiple time due to data race between local
        cancellation (by application) and Core receiving status from peer. We
        make no promise here which one will win.
        """
        # In case of local cancellation, flip the flag.
        if status.details() is _LOCAL_CANCELLATION_DETAILS:
            self._locally_cancelled = True

        # In case of the RPC finished without receiving metadata.
        if not self._initial_metadata.done():
            self._initial_metadata.set_result(_EMPTY_METADATA)

        # Sets final status
        self._status.set_result(status)
        self._code = _common.CYGRPC_STATUS_CODE_TO_STATUS_CODE[status.code()]
コード例 #5
0
    def _set_status(self, status: cygrpc.AioRpcStatus) -> None:
        """Private method to set final status of the RPC.

        This method should only be invoked once.
        """
        # In case of local cancellation, flip the flag.
        if status.details() is _LOCAL_CANCELLATION_DETAILS:
            self._locally_cancelled = True

        # In case of the RPC finished without receiving metadata.
        if not self._initial_metadata.done():
            self._initial_metadata.set_result(_EMPTY_METADATA)

        # Sets final status
        self._status.set_result(status)
        self._code = _common.CYGRPC_STATUS_CODE_TO_STATUS_CODE[status.code()]

        for callback in self._done_callbacks:
            callback(self)