Skip to content

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

Closed
@kevin-bates

Description

@kevin-bates

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions