How to use the tenacity.wait_fixed function in tenacity

To help you get started, we’ve selected a few tenacity examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CloudVE / cloudbridge / tests / helpers / standard_interface_tests.py View on Github external
                wait=tenacity.wait_fixed(10),
                reraise=True)
def check_delete(test, service, obj, perform_delete=False):
    if perform_delete:
        obj.delete()

    objs = service.list()
    found_objs = [o for o in objs if o.id == obj.id]
    test.assertTrue(
        len(found_objs) == 0,
        "Object %s in service %s should have been deleted but still exists."
        % (found_objs, type(service).__name__))
github openstack / oslo.messaging / oslo_messaging / _drivers / pika_driver / pika_message.py View on Github external
)
                return True
            else:
                return False

        if self._pika_engine.rpc_reply_retry_attempts:
            retrier = tenacity.retry(
                stop=(
                    tenacity.stop_never
                    if self._pika_engine.rpc_reply_retry_attempts == -1 else
                    tenacity.stop_after_attempt(
                        self._pika_engine.rpc_reply_retry_attempts
                    )
                ),
                retry=tenacity.retry_if_exception(on_exception),
                wait=tenacity.wait_fixed(
                    self._pika_engine.rpc_reply_retry_delay
                )
            )
        else:
            retrier = None

        try:
            timeout = (None if self.expiration_time is None else
                       max(self.expiration_time - time.time(), 0))
            with timeutils.StopWatch(duration=timeout) as stopwatch:
                reply_outgoing_message.send(
                    reply_q=self.reply_q,
                    stopwatch=stopwatch,
                    retrier=retrier
                )
            LOG.debug(
github aiogram / bot / app / utils / before_start.py View on Github external
    wait=tenacity.wait_fixed(TIMEOUT_BETWEEN_ATTEMPTS),
    stop=tenacity.stop_after_delay(MAX_TIMEOUT),
    before_sleep=before_log,
    after=after_log,
)
async def wait_redis():
    connector = BaseRedis(host=config.REDIS_HOST, port=config.REDIS_PORT, db=0)
    try:
        await connector.connect()
        info = await connector.redis.info()
        logger.info("Connected to Redis server v{redis}", redis=info["server"]["redis_version"])
    finally:
        await connector.disconnect()
github openstack / oslo.messaging / oslo_messaging / _drivers / impl_pika.py View on Github external
LOG.warning("Problem during declaring notification queue "
                                "binding. %s", e)
                return True
            elif isinstance(ex, (pika_drv_exc.ConnectionException,
                                 pika_drv_exc.MessageRejectedException)):
                LOG.warning("Problem during sending notification. %s", ex)
                return True
            else:
                return False

        if retry:
            retrier = tenacity.retry(
                stop=(tenacity.stop_never if retry == -1 else
                      tenacity.stop_after_attempt(retry)),
                retry=tenacity.retry_if_exception(on_exception),
                wait=tenacity.wait_fixed(
                    self._pika_engine.notification_retry_delay
                )
            )
        else:
            retrier = None

        msg = pika_drv_msg.PikaOutgoingMessage(self._pika_engine, message,
                                               ctxt)
        return msg.send(
            exchange=(
                target.exchange or
                self._pika_engine.default_notification_exchange
            ),
            routing_key=target.topic,
            confirm=True,
            mandatory=True,
github pythonjokeun / thewife / thewife / trade.py View on Github external
    @retry(wait=wait_fixed(5))
    def __sell_price(self):
        auth = getattr(ccxt, self.exchange)()
        return auth.fetch_order_book(self.pair)['bids'][0][0]
github openstack / qinling / qinling / orchestrator / kubernetes / manager.py View on Github external
        wait=tenacity.wait_fixed(5),
        stop=tenacity.stop_after_delay(600),
        reraise=True,
        retry=tenacity.retry_if_exception_type(exc.OrchestratorException)
    )
    def _wait_for_upgrade(self, deploy_name):
        ret = self.v1extension.read_namespaced_deployment(
            deploy_name,
            self.conf.kubernetes.namespace
        )
        if ret.status.unavailable_replicas is not None:
            raise exc.OrchestratorException("Deployment %s upgrade not "
                                            "ready." % deploy_name)
github zalando-incubator / zelt / zelt / kubernetes / client.py View on Github external
    wait=wait_fixed(KUBE_API_WAIT),
    retry=retry_if_exception_type(ResourceStillThereError),
)
def await_no_resources_found(list_resources: Callable, **kwargs):
    try:
        found = list_resources(**kwargs)
    except ApiException as err:
        if err.status == STATUS_NOT_FOUND:
            return
        raise
    if hasattr(found, "items"):
        found = found.items
    if found:
        raise ResourceStillThereError(f"Resource(s): {found} still found; retrying.")