Skip to content

Commit

Permalink
Allow contents manager get to return future
Browse files Browse the repository at this point in the history
This is a follow up to jupyter#4099,
wrapping another user of contents manager get with `maybe_future` to
allow it to yield the event loop.
  • Loading branch information
michalc committed Nov 24, 2019
1 parent 9640e1f commit c5e9201
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions notebook/notebook/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@

from collections import namedtuple
import os
from tornado import web
from tornado import (
gen, web,
)
HTTPError = web.HTTPError

from ..base.handlers import (
IPythonHandler, FilesRedirectHandler, path_regex,
)
from ..utils import url_escape
from ..utils import (
maybe_future, url_escape,
)
from ..transutils import _


Expand Down Expand Up @@ -68,6 +72,7 @@ def get_frontend_exporters():
class NotebookHandler(IPythonHandler):

@web.authenticated
@gen.coroutine
def get(self, path):
"""get renders the notebook template if a name is given, or
redirects to the '/files/' handler if the name is not given."""
Expand All @@ -76,7 +81,7 @@ def get(self, path):

# will raise 404 on not found
try:
model = cm.get(path, content=False)
model = yield maybe_future(cm.get(path, content=False))
except web.HTTPError as e:
if e.status_code == 404 and 'files' in path.split('/'):
# 404, but '/files/' in URL, let FilesRedirect take care of it
Expand Down

0 comments on commit c5e9201

Please sign in to comment.