Skip to content

Commit

Permalink
Fixes await management for AsyncContentsManager.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmarchetti authored and tdstein committed Feb 27, 2023
1 parent 4d38e49 commit 0d287e6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion rsconnect_jupyter/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import hashlib
import inspect
import json
import os
import sys
Expand Down Expand Up @@ -73,7 +74,7 @@ def md5(s):
# https://github.com/jupyter/notebook/blob/master/notebook/base/handlers.py
class EndpointHandler(APIHandler):
@web.authenticated
def post(self, action):
async def post(self, action):
data = self.get_json_body()

if action == "verify_server":
Expand Down Expand Up @@ -161,6 +162,11 @@ def post(self, action):
hide_tagged_input = data.get("hide_tagged_input", False)

model = self.contents_manager.get(path=nb_path)
if inspect.isawaitable(model):
# The default ContentsManager is now async,
# but we handle both cases.
model = await model

if model["type"] != "notebook":
# not a notebook
raise web.HTTPError(400, "Not a notebook: %s" % nb_path)
Expand Down

0 comments on commit 0d287e6

Please sign in to comment.