Retry ssh connect a few times
I'm seeing random ssh connection failures that are messing up my periodic runs of these scripts. Add a few retires for the connect attempt. Change-Id: I171328813e29a2d6141c90866d50486b500ff61a
This commit is contained in:
parent
534b394655
commit
ceb72af13a
@ -88,13 +88,26 @@ def get_changes(projects, ssh_user, ssh_key, only_open=False, stable='',
|
||||
|
||||
if not changes:
|
||||
while True:
|
||||
try:
|
||||
client.connect(server, port=29418,
|
||||
key_filename=ssh_key, username=ssh_user)
|
||||
except paramiko.SSHException:
|
||||
client.connect(server, port=29418,
|
||||
key_filename=ssh_key, username=ssh_user,
|
||||
allow_agent=False)
|
||||
connect_attempts = 3
|
||||
for attempt in range(connect_attempts):
|
||||
try:
|
||||
client.connect(server, port=29418,
|
||||
key_filename=ssh_key,
|
||||
username=ssh_user)
|
||||
except paramiko.SSHException:
|
||||
try:
|
||||
client.connect(server, port=29418,
|
||||
key_filename=ssh_key,
|
||||
username=ssh_user,
|
||||
allow_agent=False)
|
||||
except paramiko.SSHException:
|
||||
if attempt == connect_attempts + 1:
|
||||
raise
|
||||
time.sleep(3)
|
||||
continue
|
||||
# Connected successfully
|
||||
break
|
||||
|
||||
cmd = ('gerrit query %s --all-approvals --patch-sets '
|
||||
'--format JSON' % projects_q(project))
|
||||
if only_open:
|
||||
|
Loading…
Reference in New Issue
Block a user