Handle unexpected scheduler errors during runtime
@@ -205,6 +205,7 @@ class Scheduler(Invoker):
tasks = [] # type: List
current_time = time.time()
while not cls.close_waiter.done():
+ try:
last_time = current_time
actual_time = time.time()
current_time = last_time + 1 if int(last_time + 1) < int(actual_time) else actual_time
@@ -224,6 +225,10 @@ class Scheduler(Invoker):
next_call_at = None
tasks = [task for task in tasks if not task.done()]
tasks.append(asyncio.ensure_future(asyncio.shield(handler())))
+ except Exception as e:
+ if not context.get('log_level') or context.get('log_level') in ['DEBUG']:
+ traceback.print_exception(e.__class__, e, e.__traceback__)
+ await asyncio.sleep(1)
if tasks:
await asyncio.wait(tasks)
