|
4 | 4 | """
|
5 | 5 | # Copyright (c) Jupyter Development Team.
|
6 | 6 | # Distributed under the terms of the Modified BSD License.
|
| 7 | +import asyncio |
7 | 8 | import json
|
8 | 9 | from textwrap import dedent
|
9 | 10 | from traceback import format_tb
|
|
15 | 16 | except ImportError:
|
16 | 17 | from jupyter_client.jsonutil import date_default as json_default
|
17 | 18 |
|
| 19 | +from concurrent.futures import Future |
| 20 | + |
18 | 21 | from tornado import gen, web
|
19 |
| -from tornado.concurrent import Future |
20 | 22 | from tornado.ioloop import IOLoop
|
21 | 23 |
|
22 | 24 | from jupyter_server.auth import authorized
|
@@ -55,7 +57,9 @@ async def post(self):
|
55 | 57 | else:
|
56 | 58 | model.setdefault("name", km.default_kernel_name)
|
57 | 59 |
|
58 |
| - kernel_id = await km.start_kernel(kernel_name=model["name"], path=model.get("path")) |
| 60 | + kernel_id = await ensure_async( |
| 61 | + km.start_kernel(kernel_name=model["name"], path=model.get("path")) |
| 62 | + ) |
59 | 63 | model = await ensure_async(km.kernel_model(kernel_id))
|
60 | 64 | location = url_path_join(self.base_url, "api", "kernels", url_escape(kernel_id))
|
61 | 65 | self.set_header("Location", location)
|
@@ -404,7 +408,7 @@ def give_up():
|
404 | 408 | loop = IOLoop.current()
|
405 | 409 | loop.add_timeout(loop.time() + self.kernel_info_timeout, give_up)
|
406 | 410 | # actually wait for it
|
407 |
| - await future |
| 411 | + await asyncio.wrap_future(future) |
408 | 412 |
|
409 | 413 | async def get(self, kernel_id):
|
410 | 414 | self.kernel_id = kernel_id
|
|
0 commit comments