Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/third_party/python/taskcluster/taskcluster/aio/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 1 kB image not shown  

Quelle  retry.py   Sprache: Python

 
import logging
import asyncio

from .. import utils

log = logging.getLogger(__name__)


async def retry(maxRetries, tryFn):
    """
    Retry async `tryFn` based on `maxRetries`.  Each call to `tryFn` will pass a callable
    which should be called with the exception object when an exception can be retried.
    Exceptions raised from `tryFn` are treated as fatal.
    """

    retry = -1  # we plus first in the loop, and attempt 1 is retry 0
    while True:
        retry += 1

        # if this isn't the first retry then we sleep
        if retry > 0:
            snooze = float(retry * retry) / 10.0
            log.info('Sleeping %0.2f seconds for exponential backoff', snooze)
            await asyncio.sleep(utils.calculateSleepTime(retry))

        retriableException = None

        def retryFor(exc):
            nonlocal retriableException
            retriableException = exc

        res = await tryFn(retryFor)

        if not retriableException:
            return res

        if retry < maxRetries:
            log.warning(f'Retrying because of: {retriableException}')
            continue

        raise retriableException

Messung V0.5
C=88 H=95 G=91

¤ Dauer der Verarbeitung: 0.15 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.