Skip to content
This repository has been archived by the owner on Apr 22, 2020. It is now read-only.

Commit

Permalink
Work around paramiko/paramiko#673 (#27)
Browse files Browse the repository at this point in the history
* Attempt workaround for paramiko/paramiko#673
Add a delay and attempt to connect again when an SSHException occurs
  • Loading branch information
rwalton-arm authored Mar 8, 2019
1 parent 9ccb28f commit cb05374
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions mbl/cli/utils/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import functools
import logging
import platform
import time

import paramiko
import scp
Expand Down Expand Up @@ -83,11 +84,19 @@ def __init__(self, device):

def __enter__(self):
"""Enter the context, connect to the ssh session."""
self._client.connect(
self.device.address,
username=self.device.username,
password=self.device.password,
)
try:
self._client.connect(
self.device.address,
username=self.device.username,
password=self.device.password,
)
except paramiko.SSHException:
time.sleep(0.2)
self._client.connect(
self.device.address,
username=self.device.username,
password=self.device.password,
)
return self

def __exit__(self, *exception_info):
Expand Down

0 comments on commit cb05374

Please sign in to comment.