Context manager generator for retry block pattern and decorator.

The first test in the TestCase does do this to an extent, but yeah we can probably add something more comprehensive. I am kind of occupied by some other stuff, so will look at adding these over the weekend.

But is the rest fine? so that @adampalay or @zubair-arbi can start on the LMS side of the work.