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

Delay Ark startup until debugger is attached #742

Merged
merged 9 commits into from
Jun 16, 2023
Merged

Conversation

lionel-
Copy link
Contributor

@lionel- lionel- commented Jun 14, 2023

Branched from #741
Addresses #740

This PR makes it possible to automatically delay the startup of Ark until the debugger is attached to the process:

  • This is controlled by a new positron.jupyterAdapter.attachOnStartup setting. Set it to true in your settings.json to enable attach on startup.

    Edit: There is now also positron.jupyterAdapter.sleepOnStartup which can be combined with the above. Useful to attach the debugger and give some time to hit the pause button to enter some commands before resuming startup.

  • Attach on startup is supported via a new undocumented argument --startup-notifier-file passed to Ark. It takes the path to a notification file to which the frontend writes when the debugger has been attached. Ark blocks until a change to the file is detected. After that, startup continues as normal. Implemented in Add --delay-startup argument to Ark ark#35.

  • The actions of adding this argument and attaching the debugger need to be performed in the start() method of the Jupyter kernel. To support this, Jupyter kernels now optionally accept a new JupyterKernelExtra object containing custom implementations for this sort of extra functionality. This extra object is created and passed in by the Ark registration routine.

@lionel-
Copy link
Contributor Author

lionel- commented Jun 14, 2023

Is it reasonable to add this sort of debugging functionality to the jupyter interface @jmcphers? It's not meant to be a stable part of the API, it just enables a debugging/development convenience while preserving abstraction.

@lionel-
Copy link
Contributor Author

lionel- commented Jun 14, 2023

Kernels that do not support a delayed startup can still provide an attach() method that runs <f5> in parallel to startup. Perhaps we should do that by default when the attachOnStartup option is set. However that can be confusing if the user doesn't realise the debugger and the kernel are run in parallel.

@lionel- lionel- changed the base branch from upkeep/refactor-connection to main June 15, 2023 09:11
@lionel- lionel- force-pushed the feature/startup-attach branch 2 times, most recently from 71e4bbc to 716ab1d Compare June 15, 2023 09:56
@lionel- lionel- requested a review from jmcphers June 15, 2023 10:53
@lionel- lionel- force-pushed the feature/startup-attach branch from 9bd7c69 to f74a47b Compare June 15, 2023 14:07
@lionel- lionel- force-pushed the feature/startup-attach branch from 598f8b6 to 4be47ad Compare June 16, 2023 07:21
@lionel- lionel- merged commit a325fe5 into main Jun 16, 2023
@lionel- lionel- deleted the feature/startup-attach branch June 16, 2023 07:38
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.

2 participants