Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit 7f75edb

Browse files
committed
support async kernel in _request_jupyter_config
1 parent 3cd2da4 commit 7f75edb

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

jupyter_dash/comms.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import asyncio
12
import IPython
23
from ipykernel.comm import Comm
4+
import nest_asyncio
35
import time
46
import sys
57

@@ -66,7 +68,12 @@ def capture_event(stream, ident, parent):
6668
if _jupyter_comm_response_received():
6769
break
6870

69-
kernel.do_one_iteration()
71+
if asyncio.iscoroutinefunction(kernel.do_one_iteration):
72+
nest_asyncio.apply()
73+
loop = asyncio.get_event_loop()
74+
loop.run_until_complete(kernel.do_one_iteration())
75+
else:
76+
kernel.do_one_iteration()
7077

7178
# Stop capturing events, revert the kernel shell handler to the default
7279
# execute_request behavior

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ retrying
55
ipython
66
ipykernel
77
ansi2html
8+
nest-asyncio

0 commit comments

Comments
 (0)