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

Test with client 8 updates #988

Merged
merged 4 commits into from
Sep 25, 2022
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ jobs:
- name: Run the tests
run: |
pytest -vv --integration_tests=true tests
- name: Run the tests
run: |
pip install jupyter_client@https://github.com/blink1073/jupyter_client/archive/refs/heads/synchronous_managers.zip
pytest -vv --integration_tests=true tests

integration_check: # This job does nothing and is only used for the branch protection
if: always()
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ jobs:
pip check
- name: Run the tests
run: |
pip install jupyter_client@https://github.com/blink1073/jupyter_client/archive/refs/heads/synchronous_managers.zip
pytest -vv || pytest -vv --lf

make_sdist:
Expand Down
10 changes: 7 additions & 3 deletions jupyter_server/services/kernels/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import asyncio
import json
from textwrap import dedent
from traceback import format_tb
Expand All @@ -15,8 +16,9 @@
except ImportError:
from jupyter_client.jsonutil import date_default as json_default

from concurrent.futures import Future
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://docs.python.org/3/library/concurrent.futures.html#concurrent.futures.Future says:

Future instances are created by Executor.submit() and should not be created directly except for testing.

Are we not creating such Future objects in this file now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were already doing that in client for synchronous managers. I really don't see a way around it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just pinged Steve about this in a side-bar. We're seeing CI failures in the EG tests when the websocket handling encounters a busy kernel prior to the nudge. It results in the return of a Future (whose type has changed), ultimately resulting in this log sequence...

[D 2022-09-27 04:19:12.195 EnterpriseGatewayApp] Nudge: not nudging busy kernel 39ce47c4-64c4-4b0e-a2cf-4f998d1b8880
[E 220927 04:19:12 web:1793] Uncaught exception GET /api/kernels/39ce47c4-64c4-4b0e-a2cf-4f998d1b8880/channels (172.17.0.1)
    HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/api/kernels/39ce47c4-64c4-4b0e-a2cf-4f998d1b8880/channels', version='HTTP/1.1', remote_ip='172.17.0.1')
    Traceback (most recent call last):
      File "/opt/conda/lib/python3.7/site-packages/tornado/websocket.py", line 956, in _accept_connection
        await open_result
    TypeError: object Future can't be used in 'await' expression

If I revert to jupyter_server < 1.19, CI passes.


from tornado import gen, web
from tornado.concurrent import Future
from tornado.ioloop import IOLoop

from jupyter_server.auth import authorized
Expand Down Expand Up @@ -55,7 +57,9 @@ async def post(self):
else:
model.setdefault("name", km.default_kernel_name)

kernel_id = await km.start_kernel(kernel_name=model["name"], path=model.get("path"))
kernel_id = await ensure_async(
km.start_kernel(kernel_name=model["name"], path=model.get("path"))
)
model = await ensure_async(km.kernel_model(kernel_id))
location = url_path_join(self.base_url, "api", "kernels", url_escape(kernel_id))
self.set_header("Location", location)
Expand Down Expand Up @@ -404,7 +408,7 @@ def give_up():
loop = IOLoop.current()
loop.add_timeout(loop.time() + self.kernel_info_timeout, give_up)
# actually wait for it
await future
await asyncio.wrap_future(future)

async def get(self, kernel_id):
self.kernel_id = kernel_id
Expand Down