Implement user interrupt from R#276
Open
vandenman wants to merge 3 commits intoJuliaInterop:masterfrom
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Before evaluating the Julia code, we start a
Timerthat listens to:R_interrupts_pending. This idea is copied from RCall, see here, and also mentioned in a comment. WhenR_interrupts_pendingis set, we throw anInterruptException()which is then caught and we exit Julia gracefully to return control to R.Related Issue
This is related to #126, but this does not close/ restart the Julia session. It only interrupts it.
Example
Interactively, you can do the following on master:
There is no way to interrupt this. It will run until it's done, or you force quit R/ RStudio. In contrast, on this PR, you can interrupt R (e.g., press the red stop button in RStudio) and then the loop will stop.
More realistic scenarios are situations where someone accidentally runs an analysis for way more iterations than intended, and then has to choose between waiting a long time or restarting the session and loosing the interim progress.
Questions
InterruptException. We could make a custom exception,InterruptedFromRExceptionand throw that instead?I added the
renvstuff to.Rbuildignoresince this is whatrenvdoes by default. If this is a problem I'd of course be happy to revert that.Developed with Claude 🤖