how do I retry a command only for a specific exception / error

Ganesh Pal ganesh1pal at gmail.com
Wed Mar 21 09:35:37 EDT 2018


Please ensure quoted text is quoted, and new text you write is unquoted.
> That way you are more likely to get useful
>

Sorry , Steve I didn't realize but thanks for pointing out I will take care
I was on a mobile phone and messed the quoted text

>Something like this should do it. It gives up immediately on fatal >errors
>and tries again on temporary ones. (You have to specify what you >consider
>fatal or temporary, of course.

This is a good suggestion ,  I like the way the code is  written , but what
I have failed to understand is how to translate the
possible  TemporaryFailureErrors to a different exception class/type  and
retry .


 In my case ,  every  command is executed using a run() function  that
calls out to subprocess.Popen().   Which will return  stdout, stderr,
exit_code and we would need to retry only for a specific
TemporaryFailureError .



Example : Say , If we are not able to  SSH  to the host  , and I get
“connection refused” error I would want to retry only for this specific case



More information about the Python-list mailing list