Skip to content

Commit

Permalink
feat: allow connecting to a running kernel from a different browser
Browse files Browse the repository at this point in the history
This is useful for connecting external devices, such as smartphone or
AR devices (Apple Vision pro and Meta Quest) to the running kernel
using ipypopout.

This is normally not possible since we require the connecting client
to have the same session id as the already kernel.

This this setting, we can disable the session check and the above use
case.

e.g.

SOLARA_KERNEL_SESSION_CHECK=False solara run ...

setting to disable session check
  • Loading branch information
maartenbreddels committed Sep 18, 2024
1 parent 0a50779 commit 6fa5e8a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion solara/server/kernel_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ def initialize_virtual_kernel(session_id: str, kernel_id: str, websocket: websoc
if kernel_id in contexts:
logger.info("reusing virtual kernel: %s", kernel_id)
context = contexts[kernel_id]
if context.session_id != session_id:
if solara.server.settings.kernel.session_check and context.session_id != session_id:
logger.critical("Session id mismatch when reusing kernel (hack attempt?): %s != %s", context.session_id, session_id)
websocket.send_text("Session id mismatch when reusing kernel (hack attempt?)")
# to avoid very fast reconnects (we are in a thread anyway)
Expand Down
1 change: 1 addition & 0 deletions solara/server/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class Kernel(BaseSettings):
cull_timeout: str = "24h"
max_count: Optional[int] = None
threaded: bool = solara.util.has_threads
session_check: bool = True

class Config:
env_prefix = "solara_kernel_"
Expand Down

0 comments on commit 6fa5e8a

Please sign in to comment.