helper for bombing out of infinite loops

An initial take for getting rid of infinite loops.

I was not able to find a common place for teuthology exceptions so I added the custom exception in the same file. It should not be a handled one so it doesn't really matter.

Tests are included along with docs on how to use the new helper