A generic helper to help retry some action until given condition is met.