This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| from functools import wraps | |
| def retry(retries=3, delay=0.5): | |
| def decorator(func): | |
| @wraps(func) | |
| def wrapper(*args, **kwargs): | |
| for attempt in range(retries): | |
| try: | |
| return func(*args, **kwargs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import itertools | |
| import sys | |
| import time | |
| import threading | |
| def spinner(stop_event): | |
| for c in itertools.cycle('|/-\\'): | |
| if stop_event.is_set(): | |
| break | |
| sys.stdout.write(f'\rLoading {c}') |