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..bcefb01f35 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'] == 'idle' and newsession['kernel']['execution_state'] == 'starting': + 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):