Skip to content

Commit

Permalink
Check kernel id before delete and upgrade ws (#1376)
Browse files Browse the repository at this point in the history
Co-authored-by: saf <saf@zjuici.com>
  • Loading branch information
vegetablest and saf authored Jul 13, 2024
1 parent d01e84a commit ffebbaf
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions enterprise_gateway/services/kernels/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,24 @@ def get(self, kernel_id: str):
model = km.kernel_model(kernel_id)
self.finish(json.dumps(model, default=date_default))

@web.authenticated
async def delete(self, kernel_id):
"""Remove a kernel."""
self.kernel_manager.check_kernel_id(kernel_id=kernel_id)
await super().delete(kernel_id=kernel_id)


class ZMQChannelsHandler(
TokenAuthorizationMixin, CORSMixin, JSONErrorsMixin, jupyter_server_handlers.ZMQChannelsHandler
):
"""Extends the kernel websocket handler."""

async def get(self, kernel_id):
"""Handle a get request for a kernel."""
# Synchronize Kernel and check if it exists.
self.kernel_manager.check_kernel_id(kernel_id=kernel_id)
await super().get(kernel_id=kernel_id)


default_handlers: list[tuple] = []
for path, cls in jupyter_server_handlers.default_handlers:
Expand Down

0 comments on commit ffebbaf

Please sign in to comment.