From: Yonghee Han Date: Fri, 2 Feb 2018 04:58:28 +0000 (+0900) Subject: Workaround code for HTTP Error 408 X-Git-Tag: submit/trunk/20190927.012743~144^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F45%2F169045%2F2;p=services%2Fjenkins-scripts.git Workaround code for HTTP Error 408 PROBLEM : HTTP Error 408: Request Timeout SOLUTION : Retry for Error exception Change-Id: I09311b0c06c215b9d10f6c97239f7a06aebb6b8f --- diff --git a/job_repa.py b/job_repa.py index cefd655..a63eea4 100644 --- a/job_repa.py +++ b/job_repa.py @@ -32,6 +32,7 @@ import xml.etree.ElementTree as ElementTree from gbp.git.repository import GitRepositoryError from osc import core +from time import sleep from common.gerrit import Gerrit, get_gerrit_event, GerritError, is_ref_deleted from common.git import Git, clone_gitproject @@ -114,21 +115,32 @@ def accept_or_reject(build, prerelease_proj, git_tag, state, comment=''): message = "SR %s is set to %s" % (reqid, state) if comment: message += comment - build.set_sr_state(reqid, state=state, - message=str(message), force=True) - print 'set SR state to', state + + retry_count = 3 + ret = "" + while retry_count >= 0: + try: + r = build.set_sr_state(reqid, state=state, + message=str(message), force=True) + print 'set SR state to', state, r + ret = "" + break + except Exception as err: + print 'set SR error: %s Retry...' %(err) + retry_count -= 1 + ret = str(err) + sleep(1) + return ret def repa_reject(build, proj, git_tag, comment=''): try: - accept_or_reject(build, proj, git_tag, 'declined', comment) - return "" + return accept_or_reject(build, proj, git_tag, 'declined', comment) except Exception as err: return str(err) def repa_accept(build, proj, git_tag, comment=''): try: - accept_or_reject(build, proj, git_tag, 'accepted', comment) - return "" + return accept_or_reject(build, proj, git_tag, 'accepted', comment) except Exception as err: return str(err)