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

Await kernel.ready in _async_shutdown_kernel #740

Merged
merged 2 commits into from
Jan 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions jupyter_client/multikernelmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,12 @@ async def _async_shutdown_kernel(
if self._using_pending_kernels() and kernel_id in self._pending_kernels:
raise RuntimeError("Kernel is in a pending state. Cannot shutdown.")
# If the kernel is still starting, wait for it to be ready.
elif kernel_id in self._starting_kernels:
kernel = self._starting_kernels[kernel_id]
elif kernel_id in self._pending_kernels:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since _starting_kernels is a shim for _pending_kernels defined here:

@property
def _starting_kernels(self):
"""A shim for backwards compatibility."""
return self._pending_kernels

We might as well use _pending_kernels directly.

kernel = self._pending_kernels[kernel_id]
try:
await kernel
km = self.get_kernel(kernel_id)
await km.ready
except Exception:
self.remove_kernel(kernel_id)
return
Expand Down