Skip to content

Kernel manager object has no attribute 'last_activity' during culling check #5345

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

Closed
kevin-bates opened this issue Apr 7, 2020 · 0 comments · Fixed by #5355
Closed

Kernel manager object has no attribute 'last_activity' during culling check #5345

kevin-bates opened this issue Apr 7, 2020 · 0 comments · Fixed by #5355

Comments

@kevin-bates
Copy link
Member

Culling runs independently of a kernel's startup and uses the corresponding kernel manager's last_activity attribute to help determine if it should be culled or not. However, because the last_activity attribute is added to the kernel manager instance dynamically, there's a small (typically < 10ms) window where the culler sees that the KernelManager instance exists sans its last_activity attribute. This can result in the following error on the console:

[E 2020-04-07 16:15:08.965 EnterpriseGatewayApp] The following exception was encountered while checking the idle duration of kernel 0070571c-4f92-4027-b9e1-1f98cf62421d: 'RemoteKernelManager' object has no attribute 'last_activity'
    Traceback (most recent call last):
      File "/opt/anaconda2/envs/py3/lib/python3.6/site-packages/notebook/services/kernels/kernelmanager.py", line 451, in cull_kernels
        await self.cull_kernel_if_idle(kernel_id)
      File "/opt/anaconda2/envs/py3/lib/python3.6/site-packages/notebook/services/kernels/kernelmanager.py", line 463, in cull_kernel_if_idle
        kernel_id, kernel.kernel_name, kernel.last_activity)
    AttributeError: 'RemoteKernelManager' object has no attribute 'last_activity'
[I 2020-04-07 16:15:08.969 EnterpriseGatewayApp] Kernel started: 0070571c-4f92-4027-b9e1-1f98cf62421d

Notebook probably should have subclassed juptyer_client's KernelManager to host last_activity, but didn't (and it's too late for that), so we should check its existence before checking its cull status. Since this should only occur milliseconds after a kernel's startup, it won't affect the integrity of the cull.

@kevin-bates kevin-bates self-assigned this Apr 7, 2020
kevin-bates added a commit to kevin-bates/notebook that referenced this issue Apr 8, 2020

Verified

This commit was signed with the committer’s verified signature.
kevin-bates Kevin Bates
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
blink1073 pushed a commit that referenced this issue May 25, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
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
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant