From f1139dd0758df168c60e791a6ba79988394035c2 Mon Sep 17 00:00:00 2001 From: cailiang9 Date: Wed, 19 May 2021 00:29:13 +0800 Subject: [PATCH] Support AsyncFileManager --- nbclassic/tree/handlers.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/nbclassic/tree/handlers.py b/nbclassic/tree/handlers.py index 2d69d2dce..4d3fc006f 100644 --- a/nbclassic/tree/handlers.py +++ b/nbclassic/tree/handlers.py @@ -6,7 +6,7 @@ # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. -from tornado import web +from tornado import web, gen import os from jupyter_server.base.handlers import JupyterHandler @@ -15,7 +15,7 @@ ExtensionHandlerJinjaMixin ) from jupyter_server.base.handlers import path_regex -from jupyter_server.utils import url_path_join, url_escape +from jupyter_server.utils import url_path_join, url_escape, ensure_async class TreeHandler(ExtensionHandlerJinjaMixin, ExtensionHandlerMixin, JupyterHandler): @@ -44,6 +44,7 @@ def generate_page_title(self, path): return 'Home' @web.authenticated + @gen.coroutine def get(self, path=''): path = path.strip('/') cm = self.contents_manager @@ -64,7 +65,7 @@ def get(self, path=''): )) elif cm.file_exists(path): # it's not a directory, we have redirecting to do - model = cm.get(path, content=False) + model = yield ensure_async(cm.get(path, content=False)) # redirect to /api/notebooks if it's a notebook, otherwise /api/files service = 'notebooks' if model['type'] == 'notebook' else 'files' url = url_path_join(