From 0d287e6f0617382e5fdbe1213e7e08cc75f1668c Mon Sep 17 00:00:00 2001 From: Michael Marchetti Date: Fri, 24 Feb 2023 09:50:16 -0500 Subject: [PATCH] Fixes await management for AsyncContentsManager. --- rsconnect_jupyter/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/rsconnect_jupyter/__init__.py b/rsconnect_jupyter/__init__.py index e0bde7c4..dd532bd4 100644 --- a/rsconnect_jupyter/__init__.py +++ b/rsconnect_jupyter/__init__.py @@ -1,4 +1,5 @@ import hashlib +import inspect import json import os import sys @@ -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": @@ -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)