Catch some of the exceptions that can happen when failing to connect to target host.

This commit is contained in:
Cassowary Rusnov 2024-04-30 09:47:13 -07:00
parent e090c4465d
commit d8deaaf456
1 changed files with 7 additions and 1 deletions

View File

@ -5,8 +5,14 @@ from tqdm import tqdm
from fabric2 import ThreadingGroup, SerialGroup, Config, Connection
import paramiko
def thread_run(connection, command, result_lock, result_queue):
res = connection.run(command, warn=True, hide=True)
try:
res = connection.run(command, warn=True, hide=True)
except (paramiko.ssh_exception.NoValidConnectionsError, paramiko.ssh_exception.SSHException) as inst:
res = f"Could not connect to host: {inst}"
with result_lock:
result_queue.append((connection, res))