Skip to content

Commit

Permalink
display traceback info if retry times==ntimes (#755)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShenYuhan committed Aug 18, 2020
1 parent a45c354 commit f177684
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions visualdl/server/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
error_info = '\n'.join(map(str, sys.exc_info()))
logger.error("Unexpected error: %s" % error_info)
time.sleep(time2sleep)
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):
Expand Down

0 comments on commit f177684

Please sign in to comment.