1
0
Fork 0

added retry on errors

This commit is contained in:
Christian Kühnel 2019-11-05 09:27:34 +01:00
parent c05b7091c8
commit 48567c02fe

View file

@ -19,8 +19,10 @@ build status, a summary and the test reults to Phabricator."""
import argparse
import os
import time
from typing import Optional
from phabricator import Phabricator
import socket
from lxml import etree
class TestResults:
@ -166,8 +168,20 @@ class PhabTalk:
def main():
args = _parse_args()
p = PhabTalk(args.conduit_token, args.host, args.dryrun)
p.report_all(args.diff_id, args.ph_id, args.test_result_file, args.comment_file)
errorcount = 0
while True:
# retry on connenction problems
try:
p = PhabTalk(args.conduit_token, args.host, args.dryrun)
p.report_all(args.diff_id, args.ph_id, args.test_result_file, args.comment_file)
except socket.timeout as e:
errorcount += 1
if errorcount > 5:
print('Connection to Pharicator failed, giving up: {}'.format(e))
raise
print('Connection to Pharicator failed, retrying: {}'.format(e))
time.sleep(errorcount*10)
break
def _parse_args():