def _rmdir_with_retries(dirname: str, num_retries: int, delay_between_tries: float=1):
    for retry_num in range(1, (num_retries + 1)):
        if (not os.path.exists(dirname)):
            return
        try:
            shutil.rmtree(dirname)
            break
        except:
            if (retry_num < num_retries):
                print('Retrying to remove directory: {}'.format(dirname))
                time.sleep(delay_between_tries)
            else:
                raise Exception('Unable to remove directory after {} tries: {}'.format(num_retries, dirname))
def _rmdir_with_retries(dirname: str, num_retries: int, delay_between_tries: float=1):
    for retry_num in range(1, (num_retries + 1)):
        if (not os.path.exists(dirname)):
            return
        try:
            shutil.rmtree(dirname)
            break
        except:
            if (retry_num < num_retries):
                print('Retrying to remove directory: {}'.format(dirname))
                time.sleep(delay_between_tries)
            else:
                raise Exception('Unable to remove directory after {} tries: {}'.format(num_retries, dirname))