diff --git a/components/utilities.py b/components/utilities.py index 5eece93..28bca0c 100644 --- a/components/utilities.py +++ b/components/utilities.py @@ -144,12 +144,15 @@ def decorate(func): # Retry calling a function `times` times, sleeping between each tries, with an exponential backoff # This is to be used on API calls, that are likely to fail +RETRY_TIMES = 10 -def retry(_func=None, *, times=10, sleep_s=1, exp=2): + +def retry(_func=None, *, sleep_s=1, exp=2): def decorator_retry(func): @functools.wraps(func) def wrapper_retry(*args, **kwargs): - retries_try = times + global RETRY_TIMES + retries_try = RETRY_TIMES sleep_duration = sleep_s while retries_try > 0: try: diff --git a/tests/functionality_all_platforms.py b/tests/functionality_all_platforms.py index 804548c..68a204b 100755 --- a/tests/functionality_all_platforms.py +++ b/tests/functionality_all_platforms.py @@ -16,6 +16,9 @@ sys.path.append(".") sys.path.append("..") +import components.utilities +components.utilities.RETRY_TIMES = 2 + from automation import Updatebot from components.utilities import Struct, raise_, AssertFalse diff --git a/tests/functionality_commitalert.py b/tests/functionality_commitalert.py index cde37b0..ee4ae60 100755 --- a/tests/functionality_commitalert.py +++ b/tests/functionality_commitalert.py @@ -12,6 +12,9 @@ sys.path.append(".") sys.path.append("..") +import components.utilities +components.utilities.RETRY_TIMES = 2 + from automation import Updatebot from components.utilities import Struct, NeverUseMeClass diff --git a/tests/functionality_two_platforms.py b/tests/functionality_two_platforms.py index 94cabe7..d68ee0e 100755 --- a/tests/functionality_two_platforms.py +++ b/tests/functionality_two_platforms.py @@ -16,6 +16,9 @@ sys.path.append(".") sys.path.append("..") +import components.utilities +components.utilities.RETRY_TIMES = 2 + from automation import Updatebot from components.utilities import Struct, raise_, AssertFalse @@ -34,6 +37,7 @@ from tests.mock_treeherder_server import MockTreeherderServerFactory, TYPE_HEALTH from tests.database import transform_db_config_to_tmp_db + try: from localconfig import localconfig except ImportError: