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

Add option to leave kernel sessions running when Positron is closed #5899

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

jmcphers
Copy link
Collaborator

@jmcphers jmcphers commented Jan 7, 2025

This change makes it possible to close Positron but leave Python or R running, to be resumed/reconnected when Positron is opened again. A new setting controls this behavior; it lets you specify how long to let sessions run idle in the background before they are automatically closed.

image
  • Enables long-running remote kernels that can be accessed over SSH
  • For advanced users, enables faster startup and the ability to safely close Positron Desktop without losing data or interrupting computations
  • Addresses an issue with accumulated orphaned supervisor process observed in some dev environments; these processes will now clean themselves up after an hour
  • Enables testing of various "leave and come back later" scenarios on Positron Desktop that could formerly only be tested in server and/or Workbench configurations

How it Works

  1. When sessions are not specified to be closed when Positron is closed, the kernel supervisor is:
    1. started with a new --idle-shutdown-hours flag so that it shuts down on its own after all sessions have been idle for the specified number of hours
    2. started with nohup (Unix-alike) or start /b (Windows) so that it continues running outside the terminal host after Positron closes
  2. Persistent sessions are given a new SessionLocation: Machine
  3. Positron saves information about persistent sessions to durable workspace storage rather than ephemeral storage
  4. At startup, Positron checks all the persistent sessions to see if they are still valid (i.e. are still running). It reconnects to any that are, in the same way that it would reconnect to a session after a reload.

Note that all of this new behavior is opt-in; if the setting is left at its default, Positron behaves the same way it does today.

Release Notes

New Features

Bug Fixes

  • N/A

QA Notes

  • This change should not impact anything when the new setting is left at its default value.
  • If the kernel session exits while Positron is closed, Positron should not barf when it is reopened; instead, it should just start a new kernel session.
  • You really do need a full Positron restart when turning this setting on. Once on, you will find that Positron continues to connect to the persistent sessions until they time out or exited, even after turning the setting off, since the setting only applies to new sessions created in the new Positron window after changing the setting.
  • Some test speedup may be possible with this setting since it lets you repeatedly open and close Positron without waiting for runtime startup. (The downside, of course, is that subsequent opens aren't starting with a clean slate, which may or may not be important).
  • On Remote SSH, sessions will only persist when started inside a folder/workspace as the blank/empty workspace is effectively re-created every time you use it.

Copy link

github-actions bot commented Jan 7, 2025

E2E Tests 🚀  ?
This PR will run tests tagged with: @critical

@jmcphers jmcphers requested a review from sharon-wang January 7, 2025 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant