Beispiel #1
0
def _wait_30_seconds():
    """
    Backoff generator that waits for 30 seconds.
    """
    return backoff.constant(interval=30)
Beispiel #2
0
def test_constant():
    gen = backoff.constant(interval=3)
    for i in range(9):
        assert 3 == next(gen)
Beispiel #3
0
def _wait_one_minute():
    """
    Backoff generator that waits for 60 seconds.
    """
    return backoff.constant(interval=60)
Beispiel #4
0
def test_constant():
    gen = backoff.constant(interval=3)
    for i in range(9):
        assert 3 == next(gen)
Beispiel #5
0
from time import sleep
from typing import Any, Pattern

import backoff
from determined.common import api
from determined.common.api import certs
from requests.exceptions import RequestException

BACKOFF_SECONDS = 5


# Since the service is virtually inaccessible by the user unless
# the call completes, we may as well try forever or just wait for
# them to kill us.
@backoff.on_exception(  # type: ignore
    lambda: backoff.constant(interval=BACKOFF_SECONDS),
    RequestException,
    giveup=lambda e: e.response is not None and e.response.status_code < 500,
)
def post_ready(master_url: str, cert: certs.Cert, allocation_id: str):
    api.post(
        master_url,
        f"/api/v1/allocations/{allocation_id}/ready",
        {},
        cert=cert,
    )


def main(ready: Pattern):
    master_url = str(os.environ["DET_MASTER"])
    cert = certs.default_load(master_url)
        values[index] = info.to_row()

        # check for duplicate links, i.e. duplicate entries
        if info.has_discogs_link():
            if info.discogs_url not in all_links:
                all_links.add(info.discogs_url)
            else:  # exit if theres a duplicate discogs link (meaning duplicate entry)
                eprint(f"Found duplicate of {info.discogs_url}. Exiting...")
                break

    values.insert(0, header)  # put header back
    return values


@backoff.on_exception(
    lambda: backoff.constant(interval=10),
    httplib2.error.ServerNotFoundError,
    max_tries=5,
    on_backoff=backoff_hdlr,
)
def update_values(values, credentials):
    """Updates the values on the spreadsheet"""
    # Uses batchUpdate instead of update since its difficult to format 'date listened on' from FORMULA valueRenderOption
    service = discovery.build("sheets",
                              "v4",
                              credentials=credentials,
                              cache_discovery=False)
    no_of_rows = len(values)
    update_data = [
        {
            # Album, Artist, Year