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

Support AsyncFileManager #53

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
7 changes: 4 additions & 3 deletions nbclassic/tree/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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
Expand All @@ -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(
Expand Down