Skip to content
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

Prevent access through 'NoneType' when closing activity_stream #3907

Merged

Conversation

kevin-bates
Copy link
Member

Although I'm unable to reproduce the issue, its a safe change to
prevent an AttributeError from occuring ('NoneType' object has no
attribute 'close'). The user that reported this is attempting to
launch a kernel and I believe the launch only partially completed
such that kernel._activity_stream did not get established.
(This occurred from Jupyter Enterprise Gateway where we deal with remote
kernel launches across resource-managed clusters, so things are a bit
more involved relative to kernel establishment.)

Here's the traceback that occurs without this change...

[E 2018-09-10 17:31:18.897 EnterpriseGatewayApp] The following exception was encountered while checking the idle duration of kernel 389e11d9-f354-4113-8cdc-a34da14cee50: 'NoneType' object has no attribute 'close'
    Traceback (most recent call last):
      File "/opt/anaconda3/lib/python3.6/site-packages/notebook/services/kernels/kernelmanager.py", line 415, in cull_kernels
        self.cull_kernel_if_idle(kernel_id)
      File "/opt/anaconda3/lib/python3.6/site-packages/notebook/services/kernels/kernelmanager.py", line 436, in cull_kernel_if_idle
        self.shutdown_kernel(kernel_id)
      File "/opt/anaconda3/lib/python3.6/site-packages/notebook/services/kernels/kernelmanager.py", line 263, in shutdown_kernel
        kernel._activity_stream.close()
    AttributeError: 'NoneType' object has no attribute 'close'

Although I'm unable to reproduce the issue, its a safe change to
prevent an AttributeError from occuring ('NoneType' object has no
attribute 'close').  The user that reported this is attempting to
launch a kernel and I believe the launch only partially completed
such that `kernel._activity_stream` did not get established.
(This occurred from Jupyter Enterprise Gateway where we deal with remote
kernel launches across resource-managed clusters, so things are a bit
more involved relative to kernel establishment.)
@minrk minrk merged commit 8ced0dd into jupyter:master Sep 13, 2018
@minrk minrk added this to the 5.7 milestone Sep 13, 2018
@minrk
Copy link
Member

minrk commented Sep 13, 2018

Thanks!

@kevin-bates kevin-bates deleted the prevent-AttributeError-on-shutdown branch June 26, 2019 22:13
@kevin-bates kevin-bates restored the prevent-AttributeError-on-shutdown branch June 26, 2019 22:13
@kevin-bates kevin-bates deleted the prevent-AttributeError-on-shutdown branch June 26, 2019 22:13
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants