From 2beeaa0932a529de6cc47882c5bc2486db0fefb3 Mon Sep 17 00:00:00 2001 From: Min RK Date: Thu, 14 Sep 2017 11:37:34 +0200 Subject: [PATCH] avoid error if another traitlets Application is initialized encountered when doing db debugging in IPython --- jupyterhub/alembic/env.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/jupyterhub/alembic/env.py b/jupyterhub/alembic/env.py index 81eca8ee..15399b9f 100644 --- a/jupyterhub/alembic/env.py +++ b/jupyterhub/alembic/env.py @@ -12,9 +12,16 @@ config = context.config # Interpret the config file for Python logging. # This line sets up loggers basically. if 'jupyterhub' in sys.modules: + from traitlets.config import MultipleInstanceError from jupyterhub.app import JupyterHub + app = None if JupyterHub.initialized(): - app = JupyterHub.instance() + try: + app = JupyterHub.instance() + except MultipleInstanceError: + # could have been another Application + pass + if app is not None: alembic_logger = logging.getLogger('alembic') alembic_logger.propagate = True alembic_logger.parent = app.log