On Fri, 16 Mar 2018 11:04:22 +0530, Ganesh Pal wrote: > All that I am trying to do here is write a generic function that will > re-retry > the command few more times before failing the test
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.) It uses exponential backup to wait longer and longer each time you fail, before eventually giving up. delay = 2 for attempts in range(max_attempts): try: command() except PermanentFailureError: raise except TemporaryFailureError: sleep(delay) delay *= 2 else: break else: raise RuntimeError("too many attempts") -- Steve -- https://mail.python.org/mailman/listinfo/python-list