Пример #1
0
    def wait_for_server_channel_state(
            self,
            state: _ChannelzChannelState,
            *,
            timeout: Optional[_timedelta] = None,
            rpc_deadline: Optional[_timedelta] = None) -> _ChannelzChannel:
        # When polling for a state, prefer smaller wait times to avoid
        # exhausting all allowed time on a single long RPC.
        if rpc_deadline is None:
            rpc_deadline = _timedelta(seconds=30)

        # Fine-tuned to wait for the channel to the server.
        retryer = retryers.exponential_retryer_with_timeout(
            wait_min=_timedelta(seconds=10),
            wait_max=_timedelta(seconds=25),
            timeout=_timedelta(minutes=5) if timeout is None else timeout)

        logger.info('Waiting for client %s to report a %s channel to %s',
                    self.ip, _ChannelzChannelState.Name(state),
                    self.server_target)
        channel = retryer(self.find_server_channel_with_state,
                          state,
                          rpc_deadline=rpc_deadline)
        logger.info('Client %s channel to %s transitioned to state %s:\n%s',
                    self.ip, self.server_target,
                    _ChannelzChannelState.Name(state), channel)
        return channel
Пример #2
0
 def wrap_retry_on_etag_conflict(*args, **kwargs):
     retryer = retryers.exponential_retryer_with_timeout(
         retry_on_exceptions=(EtagConflict, gcp.api.TransportError),
         wait_min=_timedelta(seconds=1),
         wait_max=_timedelta(seconds=10),
         timeout=_timedelta(minutes=2))
     return retryer(func, *args, **kwargs)
Пример #3
0
    def wait_for_server_channel_state(
            self,
            state: _ChannelzChannelState,
            *,
            timeout: Optional[_timedelta] = None) -> _ChannelzChannel:
        # Fine-tuned to wait for the channel to the server.
        retryer = retryers.exponential_retryer_with_timeout(
            wait_min=_timedelta(seconds=10),
            wait_max=_timedelta(seconds=25),
            timeout=_timedelta(minutes=3) if timeout is None else timeout)

        logger.info('Waiting for client %s to report a %s channel to %s',
                    self.ip, _ChannelzChannelState.Name(state),
                    self.server_target)
        channel = retryer(self.find_server_channel_with_state, state)
        logger.info('Client %s channel to %s transitioned to state %s:\n%s',
                    self.ip, self.server_target,
                    _ChannelzChannelState.Name(state), channel)
        return channel