From f177684df4f015ff6a54ffe9627b30d734848cda Mon Sep 17 00:00:00 2001 From: ShenYuhan Date: Tue, 18 Aug 2020 11:44:49 +0800 Subject: [PATCH] display traceback info if retry times==ntimes (#755) --- visualdl/server/lib.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/visualdl/server/lib.py b/visualdl/server/lib.py index 3ed50dba..7976fd45 100644 --- a/visualdl/server/lib.py +++ b/visualdl/server/lib.py @@ -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): -- GitLab