def retry(func: Callable[[], T]) -> T:
""" Retry the function with 30 second timeouts until it works
- I've observed the getFirefoxDriver() without this freeze once (out of hundreds of runs...) so adding this
as a safety measure. """
for i in range(10):
if config.DEBUG and i > 0:
print("Retry #%s" % str(i))
def timeoutHandler(signum, frame):
raise TimeoutException("Timeout!")
signal.signal(signal.SIGALRM, timeoutHandler)
signal.alarm(delayTime)
try:
t = func()
signal.alarm(0)
return t
except TimeoutException:
pass
signal.alarm(0)
raise TimeoutException("Retried 10 times... Failed!")
评论列表
文章目录