From f88bcef5c051054296d9546171659a6fa4fbe0ce Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Fri, 16 Apr 2021 09:29:53 +0200 Subject: [PATCH] do not stop daemon when on_join failed --- src/risotto/register.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/risotto/register.py b/src/risotto/register.py index a4b3ad5..b37037b 100644 --- a/src/risotto/register.py +++ b/src/risotto/register.py @@ -7,6 +7,7 @@ from typing import Callable, Optional, List from asyncpg import create_pool from json import dumps, loads from pkg_resources import iter_entry_points +from traceback import print_exc import risotto from .utils import _ from .error import RegistrationError @@ -319,7 +320,13 @@ class RegisterDispatcher: await log.info_msg(risotto_context, None, info_msg) - await module.on_join(risotto_context) + try: + await module.on_join(risotto_context) + except Exception as err: + if get_config()['global']['debug']: + print_exc() + msg = _(f'on_join returns an error in module {submodule_name}: {err}') + await log.error_msg(risotto_context, {}, msg) async def load(self): # valid function's arguments