def _retry_func(func, param, num, retry_notif, error_msg):
for retry_num in range(num):<EOL><INDENT>if retry_num:<EOL><INDENT>retry_notif(param, retry_num)<EOL><DEDENT>try:<EOL><INDENT>func(param)<EOL>return<EOL><DEDENT>except DatacatsError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>raise DatacatsError(error_msg)<EOL>
A function which retries a given function num times and calls retry_notif each
time the function is retried.
:param func: The function to retry num times.
:param num: The number of times to try before giving up.
:param retry_notif: Will be called with the same parameter as func if we have to retry the
                    function. Will also receive the number of retries so far as a second
                    parameter.
:param: error_msg: The message

Throws DatacatsError if we run out of retries. Returns otherwise.