Skip to content

Commit b8e4e5a

Browse files
committed
Call tornado StaticFileHandler.get() as a coroutine
1 parent 6c0b387 commit b8e4e5a

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

kernel_gateway/jupyter_websocket/handlers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Distributed under the terms of the Modified BSD License.
33
"""Tornado handlers for kernel specs."""
44

5-
from tornado import web
5+
from tornado import gen, web
66
from ..mixins import TokenAuthorizationMixin, CORSMixin, JSONErrorsMixin
77
import os
88

@@ -22,12 +22,14 @@ def initialize(self):
2222
"""
2323
web.StaticFileHandler.initialize(self, path=os.path.dirname(__file__))
2424

25+
@gen.coroutine
2526
def get(self):
2627
"""Handler for a get on a specific handler
2728
"""
2829
resource_name, content_type = self.get_resource_metadata()
2930
self.set_header('Content-Type', content_type)
30-
return web.StaticFileHandler.get(self, resource_name)
31+
res = web.StaticFileHandler.get(self, resource_name)
32+
yield gen.maybe_future(res)
3133

3234
def options(self, **kwargs):
3335
"""Method for properly handling CORS pre-flight"""

kernel_gateway/notebook_http/handlers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,5 +260,7 @@ def initialize(self, path):
260260
self.dirname, self.filename = os.path.split(path)
261261
super(NotebookDownloadHandler, self).initialize(self.dirname)
262262

263+
@gen.coroutine
263264
def get(self, include_body=True):
264-
super(NotebookDownloadHandler, self).get(self.filename, include_body)
265+
res = super(NotebookDownloadHandler, self).get(self.filename, include_body)
266+
yield gen.maybe_future(res)

0 commit comments

Comments
 (0)