Skip to content

Commit d201529

Browse files
Fix nbconvert handler run_sync() (#667)
1 parent 923a828 commit d201529

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

jupyter_server/nbconvert/handlers.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ async def get(self, format, path):
119119
# Exporting can take a while, delegate to a thread so we don't block the event loop
120120
try:
121121
output, resources = await run_sync(
122-
exporter.from_notebook_node(nb, resources=resource_dict)
122+
lambda: exporter.from_notebook_node(nb, resources=resource_dict)
123123
)
124124
except Exception as e:
125125
self.log.exception("nbconvert failed: %s", e)
@@ -146,22 +146,22 @@ class NbconvertPostHandler(JupyterHandler):
146146
SUPPORTED_METHODS = ("POST",)
147147

148148
@web.authenticated
149-
def post(self, format):
149+
async def post(self, format):
150150
exporter = get_exporter(format, config=self.config)
151151

152152
model = self.get_json_body()
153153
name = model.get("name", "notebook.ipynb")
154154
nbnode = from_dict(model["content"])
155155

156156
try:
157-
output, resources = exporter.from_notebook_node(
158-
nbnode,
159-
resources={
160-
"metadata": {
161-
"name": name[: name.rfind(".")],
157+
output, resources = await run_sync(
158+
lambda: exporter.from_notebook_node(
159+
nbnode,
160+
resources={
161+
"metadata": {"name": name[: name.rfind(".")]},
162+
"config_dir": self.application.settings["config_dir"],
162163
},
163-
"config_dir": self.application.settings["config_dir"],
164-
},
164+
)
165165
)
166166
except Exception as e:
167167
raise web.HTTPError(500, "nbconvert failed: %s" % e) from e

0 commit comments

Comments
 (0)