diff --git a/panel/io/server.py b/panel/io/server.py index f7cade70f0..80f4a15da2 100644 --- a/panel/io/server.py +++ b/panel/io/server.py @@ -522,11 +522,17 @@ def create_static_handler(prefix, key, app): # Bokeh 2.4.x patches the asyncio event loop policy but Tornado 6.1 # support the WindowsProactorEventLoopPolicy so we restore it. +try: + JUPYTER_CONTEXT = get_ipython() is not None # noqa +except Exception: + JUPYTER_CONTEXT = False + if ( sys.platform == 'win32' and sys.version_info[:3] >= (3, 8, 0) and tornado.version_info >= (6, 1) and - type(asyncio.get_event_loop_policy()) is asyncio.WindowsSelectorEventLoopPolicy + type(asyncio.get_event_loop_policy()) is asyncio.WindowsSelectorEventLoopPolicy and + not JUPYTER_CONTEXT ): asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy())