-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Culling: ensure last_activity attr exists before use #5355
Conversation
KernelManager's last_activity attribute is added following the instance's creation. Culling (independently) uses this attribute and should ensure it exists prior to its use, else skip the culling check for that instance. Fixes jupyter#5345
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@@ -459,9 +459,9 @@ async def cull_kernel_if_idle(self, kernel_id): | |||
except KeyError: | |||
return # KeyErrors are somewhat expected since the kernel can be shutdown as the culling check is made. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -234,3 +235,49 @@ class KernelFilterTest(NotebookTestBase): | |||
# Sanity check verifying that the configurable was properly set. | |||
def test_config(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
236
@@ -234,3 +235,49 @@ class KernelFilterTest(NotebookTestBase): | |||
# Sanity check verifying that the configurable was properly set. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
235
@@ -459,9 +459,9 @@ async def cull_kernel_if_idle(self, kernel_id): | |||
except KeyError: | |||
return # KeyErrors are somewhat expected since the kernel can be shutdown as the culling check is made. | |||
|
|||
self.log.debug("kernel_id=%s, kernel_name=%s, last_activity=%s", | |||
kernel_id, kernel.kernel_name, kernel.last_activity) | |||
if kernel.last_activity is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if
def test_culling(self): | ||
kid = self.kern_api.start().json()['id'] | ||
ws = self.kern_api.websocket(kid) | ||
model = self.kern_api.get(kid).json() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heads-up: this test has a race condition. On slower hardware the kernel is already culled by the time the model is fetched and the assertion below fails. Example build failure: https://hydra.nixos.org/build/134833130
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you Matej. Yeah, I raised this suspicion in the jupyter_server meeting the other day and believe 2 seconds is a bit short. I think extending the idle timeout to 5 seconds - given this is the only test like this - will be sufficient.
KernelManager's last_activity attribute is added following the instance's
creation. Culling (independently) uses this attribute and should ensure
it exists prior to its use, else skip the culling check for that instance.
Fixes #5345