From c39c60bec7b0209255bfa2b7c83bc3a9deac568f Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 22 Nov 2021 14:13:23 -0600 Subject: [PATCH] fix handling of kernel activity --- jupyter_server/services/kernels/kernelmanager.py | 2 +- jupyter_server/tests/services/sessions/test_api.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/jupyter_server/services/kernels/kernelmanager.py b/jupyter_server/services/kernels/kernelmanager.py index b9d10fe520..b724d12f22 100644 --- a/jupyter_server/services/kernels/kernelmanager.py +++ b/jupyter_server/services/kernels/kernelmanager.py @@ -527,7 +527,7 @@ def record_activity(msg_list): def stop_watching_activity(self, kernel_id): """Stop watching IOPub messages on a kernel for activity.""" kernel = self._kernels[kernel_id] - if kernel._activity_stream: + if getattr(kernel, '_activity_stream', None): kernel._activity_stream.close() kernel._activity_stream = None diff --git a/jupyter_server/tests/services/sessions/test_api.py b/jupyter_server/tests/services/sessions/test_api.py index f5ac4ea96a..320d010a68 100644 --- a/jupyter_server/tests/services/sessions/test_api.py +++ b/jupyter_server/tests/services/sessions/test_api.py @@ -1,4 +1,5 @@ import json +import os import shutil import time @@ -246,7 +247,8 @@ async def test_create_bad_pending( resp = await session_client.list() session = j(resp)[0] assert session["kernel"]["execution_state"] == "dead" - assert "non_existent_path" in session["kernel"]["reason"] + if os.name != "nt": + assert "non_existent_path" in session["kernel"]["reason"] # Need to find a better solution to this. await session_client.cleanup()