From 29a650be76f6483b6870c6688f7439e3c399551a Mon Sep 17 00:00:00 2001 From: Kevin Bates Date: Thu, 10 Oct 2019 14:50:22 -0700 Subject: [PATCH] Fix SessionHandler call to start kernel --- jupyter_server/services/sessions/handlers.py | 4 ++-- .../services/sessions/tests/test_sessions_api.py | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/jupyter_server/services/sessions/handlers.py b/jupyter_server/services/sessions/handlers.py index ecd42e04ce..fa6ea66203 100644 --- a/jupyter_server/services/sessions/handlers.py +++ b/jupyter_server/services/sessions/handlers.py @@ -132,9 +132,9 @@ def patch(self, session_id): changes['kernel_id'] = kernel_id elif model['kernel'].get('name') is not None: kernel_name = model['kernel']['name'] - kernel_id = sm.start_kernel_for_session( + kernel_id = yield maybe_future(sm.start_kernel_for_session( session_id, kernel_name=kernel_name, name=before['name'], - path=before['path'], type=before['type']) + path=before['path'], type=before['type'])) changes['kernel_id'] = kernel_id yield maybe_future(sm.update_session(session_id, **changes)) diff --git a/jupyter_server/services/sessions/tests/test_sessions_api.py b/jupyter_server/services/sessions/tests/test_sessions_api.py index d0d8345987..f22b104844 100644 --- a/jupyter_server/services/sessions/tests/test_sessions_api.py +++ b/jupyter_server/services/sessions/tests/test_sessions_api.py @@ -132,9 +132,15 @@ def test_create(self): sid = newsession['id'] got = self.sess_api.get(sid).json() - # Kernel state may have changed from 'starting' to 'idle' - del got['kernel']['execution_state'] - del newsession['kernel']['execution_state'] + # Kernel state may have changed from 'starting' to 'idle', + # but let's only clean up if that's the case + if got['kernel']['execution_state'] == 'starting' and newsession['kernel']['execution_state'] == 'idle': + del got['kernel']['execution_state'] + del newsession['kernel']['execution_state'] + # include their last_activity as well + del got['kernel']['last_activity'] + del newsession['kernel']['last_activity'] + self.assertEqual(got, newsession) def test_create_file_session(self):