Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nbconvert handler run_sync() #667

Merged
merged 1 commit into from
Jan 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions jupyter_server/nbconvert/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ async def get(self, format, path):
# Exporting can take a while, delegate to a thread so we don't block the event loop
try:
output, resources = await run_sync(
exporter.from_notebook_node(nb, resources=resource_dict)
lambda: exporter.from_notebook_node(nb, resources=resource_dict)
)
except Exception as e:
self.log.exception("nbconvert failed: %s", e)
Expand All @@ -146,22 +146,22 @@ class NbconvertPostHandler(JupyterHandler):
SUPPORTED_METHODS = ("POST",)

@web.authenticated
def post(self, format):
async def post(self, format):
exporter = get_exporter(format, config=self.config)

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

try:
output, resources = exporter.from_notebook_node(
nbnode,
resources={
"metadata": {
"name": name[: name.rfind(".")],
output, resources = await run_sync(
lambda: exporter.from_notebook_node(
nbnode,
resources={
"metadata": {"name": name[: name.rfind(".")]},
"config_dir": self.application.settings["config_dir"],
},
"config_dir": self.application.settings["config_dir"],
},
)
)
except Exception as e:
raise web.HTTPError(500, "nbconvert failed: %s" % e) from e
Expand Down