From c0ac3bf4b55d488529a67f1baadd080ff4a309c7 Mon Sep 17 00:00:00 2001 From: chengmo Date: Thu, 11 Jun 2020 14:22:19 +0800 Subject: [PATCH] fix ci error code --- core/trainer.py | 32 ++++++++++++++++---------------- run.py | 6 +----- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/core/trainer.py b/core/trainer.py index 9694d0d0..eeadca80 100755 --- a/core/trainer.py +++ b/core/trainer.py @@ -191,17 +191,10 @@ class Trainer(object): None : run a processor for this status """ status = context['status'] - try: - if status in self._status_processor: - self._status_processor[context['status']](context) - else: - self.other_status_processor(context) - except Exception as err: - traceback.print_exc() - print('Catch Exception:%s' % str(err)) - sys.stdout.flush() - self._context['is_exit'] = self.handle_processor_exception( - status, context, err) + if status in self._status_processor: + self._status_processor[context['status']](context) + else: + self.other_status_processor(context) def other_status_processor(self, context): """ @@ -218,7 +211,7 @@ class Trainer(object): Return: bool exit_app or not """ - print('Exit app. catch exception in precoss status:%s, except:%s' % + print('Exit app. catch exception in precoss status: [%s], except: %s' % (context['status'], str(exception))) return True @@ -233,10 +226,17 @@ class Trainer(object): keep running by statu context. """ while True: - self.reload_train_context() - self.context_process(self._context) - if self._context['is_exit']: - break + try: + self.reload_train_context() + self.context_process(self._context) + if self._context['is_exit']: + break + except Exception as err: + traceback.print_exc() + print('Catch Exception:%s' % str(err)) + sys.stdout.flush() + self.handle_processor_exception(status, context, err) + sys.exit(type(err).__name__) def user_define_engine(engine_yaml): diff --git a/run.py b/run.py index ea55af78..23a55d58 100755 --- a/run.py +++ b/run.py @@ -449,8 +449,4 @@ if __name__ == "__main__": engine_registry() which_engine = get_engine(args) engine = which_engine(args) - try: - engine.run() - sys.exit(0) - except: - sys.exit(1) + engine.run() -- GitLab