def _abortion(rpc_error_call):
    code = rpc_error_call.code()
    pair = _STATUS_CODE_TO_ABORTION_KIND_AND_ABORTION_ERROR_CLASS.get(code)
    error_kind = face.Abortion.Kind.LOCAL_FAILURE if pair is None else pair[0]
    return face.Abortion(error_kind, rpc_error_call.initial_metadata(),
                         rpc_error_call.trailing_metadata(), code,
                         rpc_error_call.details())
示例#2
0
    terminated: A boolean indicating whether or not the RPC has terminated.
    abortion: A face.Abortion value describing the RPC's abortion or None if the
      RPC did not abort.
    abortion_error: A face.AbortionError describing the RPC's abortion or None
      if the RPC did not abort.
  """


_NOT_TERMINATED = _Termination(False, None, None)

_OPERATION_OUTCOME_KIND_TO_TERMINATION_CONSTRUCTOR = {
    base.Outcome.Kind.COMPLETED:
    lambda *unused_args: _Termination(True, None, None),
    base.Outcome.Kind.CANCELLED:
    lambda *args: _Termination(
        True, face.Abortion(face.Abortion.Kind.CANCELLED, *args),
        face.CancellationError(*args)),
    base.Outcome.Kind.EXPIRED:
    lambda *args: _Termination(
        True, face.Abortion(face.Abortion.Kind.EXPIRED, *args),
        face.ExpirationError(*args)),
    base.Outcome.Kind.LOCAL_SHUTDOWN:
    lambda *args: _Termination(
        True, face.Abortion(face.Abortion.Kind.LOCAL_SHUTDOWN, *args),
        face.LocalShutdownError(*args)),
    base.Outcome.Kind.REMOTE_SHUTDOWN:
    lambda *args: _Termination(
        True, face.Abortion(face.Abortion.Kind.REMOTE_SHUTDOWN, *args),
        face.RemoteShutdownError(*args)),
    base.Outcome.Kind.RECEPTION_FAILURE:
    lambda *args: _Termination(