def retry(self, retries, task_f, check_f=bool, wait_f=None):
for attempt in range(retries):<EOL><INDENT>ret = task_f()<EOL>if check_f(ret):<EOL><INDENT>return ret<EOL><DEDENT>if attempt < retries - <NUM_LIT:1> and wait_f is not None:<EOL><INDENT>wait_f(attempt)<EOL><DEDENT><DEDENT>raise RetryException("<STR_LIT>".format(retries))<EOL>
Try a function up to n times.
Raise an exception if it does not pass in time

:param retries int: The number of times to retry
:param task_f func: The function to be run and observed
:param func()bool check_f: a function to check if task_f is complete
:param func()bool wait_f: a function to run between checks