Skip to content

[Feature] The code should retry fetching the data if the connection fails  #13

@DragonWarrior15

Description

@DragonWarrior15

Currently the code does not support any kind of retry in order to call the api again to fetch the results. The following piece of code might work for this (this will be wrapped around the base api call so that modifications are needed at only one place)

success = False
for i in range(Constants.max_retries):
    if(success):
        break
    try:
        some_result = api_call()
        success = True
    except Exception as e:
        # wait few sec and continue
        time.sleep(Constants.sleep_time)
        continue

We could keep Constants.max_retries as 3 and Constants.sleep_time as 2.
I am not sure if this is the best way to do this, but if this is something useful, I can add it to the code with a PR. This is useful in cases where the API may not be reachable, or when any part of the package, or an external user is running a loop which calls the api multiple times.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions