未验证 提交 f177684d 编写于 作者: 走神的阿圆's avatar 走神的阿圆 提交者: GitHub

display traceback info if retry times==ntimes (#755)

上级 a45c354e
......@@ -226,17 +226,21 @@ def get_graph(log_reader):
def retry(ntimes, function, time2sleep, *args, **kwargs):
'''
"""
try to execute `function` `ntimes`, if exception catched, the thread will
sleep `time2sleep` seconds.
'''
"""
for i in range(ntimes):
try:
return function(*args, **kwargs)
except Exception:
if i < ntimes-1:
error_info = '\n'.join(map(str, sys.exc_info()))
logger.error("Unexpected error: %s" % error_info)
time.sleep(time2sleep)
else:
import traceback
traceback.print_exc()
def cache_get(cache):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册