Skip to content

Commit c5e9201

Browse files
committed
Allow contents manager get to return future
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.
1 parent 9640e1f commit c5e9201

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

notebook/notebook/handlers.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@
55

66
from collections import namedtuple
77
import os
8-
from tornado import web
8+
from tornado import (
9+
gen, web,
10+
)
911
HTTPError = web.HTTPError
1012

1113
from ..base.handlers import (
1214
IPythonHandler, FilesRedirectHandler, path_regex,
1315
)
14-
from ..utils import url_escape
16+
from ..utils import (
17+
maybe_future, url_escape,
18+
)
1519
from ..transutils import _
1620

1721

@@ -68,6 +72,7 @@ def get_frontend_exporters():
6872
class NotebookHandler(IPythonHandler):
6973

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

7782
# will raise 404 on not found
7883
try:
79-
model = cm.get(path, content=False)
84+
model = yield maybe_future(cm.get(path, content=False))
8085
except web.HTTPError as e:
8186
if e.status_code == 404 and 'files' in path.split('/'):
8287
# 404, but '/files/' in URL, let FilesRedirect take care of it

0 commit comments

Comments
 (0)