Skip to content

Commit 6b0ec9f

Browse files
authored
Upgrade to support jupyter_client 8 (#1778)
When upgrading the dependency spec to include v8, some python tests broke (see #1728). The tests were failing with a timeout due to indefinitely blocked IO. This originates in an infinitely-looping notebook and is caused by a misconfiguration of the client connection. Currently using `nbclient.NotebookClient` with a `jupyter_client.manager.KernelManager` results in a deadlock. nbclient doesn't seem aware of this issue because there is no test covering it. `NotebookClient` uses `AsyncKernelManager` by default. So why isn't nbgrader using it? nbgrader uses the NotebookClient via nbconvert which just realized the same issue. Up until v7.3.1, nbconvert has been hard-coding the default kernel manager to the sync version. (see jupyter/nbconvert#1964) Rather than require nbconvert>=7.3.1, this commit sets our own default value to the async kernel manager.
1 parent 3177072 commit 6b0ec9f

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

nbgrader/preprocessors/execute.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from . import NbGraderPreprocessor
66
from nbconvert.exporters.exporter import ResourcesDict
77
from nbformat.notebooknode import NotebookNode
8+
from jupyter_client.manager import AsyncKernelManager
89
from typing import Any, Optional, Tuple
910

1011

@@ -67,6 +68,11 @@ class Execute(NbGraderPreprocessor, ExecutePreprocessor):
6768
""")
6869
).tag(config=True)
6970

71+
def __init__(self, *args, **kwargs):
72+
# nbconvert < 7.3.1 used the sync version of this, which doesn't work for us.
73+
kwargs.setdefault('kernel_manager_class', AsyncKernelManager)
74+
super().__init__(*args, **kwargs)
75+
7076
def on_cell_executed(self, **kwargs):
7177
cell = kwargs['cell']
7278
reply = kwargs['execute_reply']

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ dependencies = [
3636
"ipywidgets>=7.6",
3737
"Jinja2>=3",
3838
"jsonschema>=3",
39-
"jupyter_client<8",
39+
"jupyter_client<9",
4040
"jupyter_server>=1.12,<2",
4141
"jupyterlab<4",
4242
"jupyterlab_server",

0 commit comments

Comments
 (0)