Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak the local logging behavior to use the exception explicitly provided #380

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions apis/phabricator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import json
import platform

from components.utilities import retry
from components.utilities import retry, RETRY_TIMES
from components.logging import logEntryExit, LogLevel
from components.providerbase import BaseProvider, INeedsCommandProvider, INeedsLoggingProvider

Expand Down Expand Up @@ -37,7 +37,7 @@ def __init__(self, config):
self.url = config['url']

@logEntryExit
@retry
@retry(times=RETRY_TIMES)
def submit_patches(self, bug_id, has_patches):
phab_revisions = []

Expand Down Expand Up @@ -89,7 +89,7 @@ def submit_to_phabricator(rev_id):
return phab_revisions

@logEntryExit
@retry
@retry(times=RETRY_TIMES)
def set_reviewer(self, phab_revision, phab_username):
# We have to call a different API endpoint if this is a review group
if phab_username[0] == "#":
Expand Down Expand Up @@ -123,7 +123,7 @@ def set_reviewer(self, phab_revision, phab_username):
raise Exception("Got an error from phabricator when trying to set reviewers to %s (%s) for %s: %s" % (phab_username, phid, phab_revision, result))

@logEntryExit
@retry
@retry(times=RETRY_TIMES)
def abandon(self, phab_revision):
cmd = "echo " + quote_echo_string("""{"transactions": [{"type":"abandon", "value":true}],"objectIdentifier": "%s"}""" % phab_revision)
cmd += " | %s call-conduit --conduit-uri=%s differential.revision.edit --""" % (_arc(), self.url)
Expand Down
4 changes: 2 additions & 2 deletions apis/taskcluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from collections import defaultdict
from urllib.parse import quote_plus

from components.utilities import retry, Struct, merge_dictionaries, PUSH_HEALTH_IGNORED_DICTS, PUSH_HEALTH_IGNORED_KEYS
from components.utilities import retry, RETRY_TIMES, Struct, merge_dictionaries, PUSH_HEALTH_IGNORED_DICTS, PUSH_HEALTH_IGNORED_KEYS
from components.logging import logEntryExit, logEntryExitNoArgs, LogLevel
from components.providerbase import BaseProvider, INeedsCommandProvider, INeedsLoggingProvider

Expand Down Expand Up @@ -149,7 +149,7 @@ def _vcs_setup(self):
self._vcs_setup_initialized = True

@logEntryExit
@retry
@retry(times=RETRY_TIMES)
def submit_to_try(self, library, platform_filter, recursed=0):
self._vcs_setup()
if not platform_filter:
Expand Down
4 changes: 3 additions & 1 deletion components/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,10 @@ 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, *, times=RETRY_TIMES, sleep_s=1, exp=2):
def decorator_retry(func):
@functools.wraps(func)
def wrapper_retry(*args, **kwargs):
Expand Down
3 changes: 3 additions & 0 deletions tests/functionality_all_platforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions tests/functionality_commitalert.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions tests/functionality_two_platforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
Loading