From 579abf3afc8fbfec0d3e45c8660999067c6a7f30 Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Mitterer Date: Tue, 30 Nov 2021 17:48:10 +0100 Subject: [PATCH] Add socket timeout errors to list of exceptions --- classes/retry.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/classes/retry.py b/classes/retry.py index a845b5d..0274b0b 100644 --- a/classes/retry.py +++ b/classes/retry.py @@ -1,4 +1,5 @@ from paramiko.ssh_exception import SSHException, NoValidConnectionsError +from socket import timeout class retry: """Decorator used to automatically retry operations throwing exceptions @@ -9,10 +10,11 @@ class retry: Args: exceptions (tuple, optional): A tuple containing exception classes that should be handled by the decorator. If none, handle only - paramiko.ssh_exception.SSHException/NoValidConnectionsError. - Defaults to None. + paramiko.ssh_exception.SSHException/NoValidConnectionsError and + socket.timeout/TimeoutError. Defaults to None. """ - self.exceptions = exceptions or (SSHException, NoValidConnectionsError) + self.exceptions = exceptions or (SSHException, NoValidConnectionsError, + timeout, TimeoutError) def __call__(self, f): """Return a function through the retry decorator