-
Notifications
You must be signed in to change notification settings - Fork 24
Incorporate Kernel methods in the R thread
#57
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
Merged
Merged
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
kevinushey
approved these changes
Jun 27, 2023
Contributor
kevinushey
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
jmcphers
approved these changes
Jun 27, 2023
And handle kernel requests from a new shell thread
And move ownership of the transmission side to the main R thread
Co-authored-by: Kevin Ushey <kevinushey@gmail.com>
ca8ad51 to
518dbf8
Compare
b1344bb to
099844d
Compare
DavisVaughan
reviewed
Jul 6, 2023
Comment on lines
+204
to
+207
| /// Represents whether an error occurred during R code execution. | ||
| pub error_occurred: bool, | ||
| pub error_message: String, // `evalue` in the Jupyter protocol | ||
| pub error_traceback: Vec<String>, |
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth aggregating into something like
pub error: Option<RError>
// with this separately as the error
struct RError {
pub message: String,
pub traceback: Vec<String>
}
I can think about that
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.
Replaces #54.
Branched from #52
This refactoring intends to reduce the complexity of our concurrency model by incorporating as much functionality as possible into the R thread.
The
ReadConsole()callback now pulls execution requests from thesocket-shellthread in place of theark-executionthread which is now removed. Other requests that need to run concurrently to R are run from a newark-shellthread owned byShell.Correspondingly the
Requestenum is split into two enumsRRequest(requests for the main thread) andKernelRequest(requests for theKernelobject shared among R, Shell, and LSP).The execute request/response methods now live in
interface.rsand no longer communicate across threads via channels. Everything ininterface.rsruns synchronously with R and so this code may now be considered single-threaded regarding the use of R and conceptually does not need the R lock (though we still should user_lock!to protect against interrupts or perhaps add another macro for that purpose). This should make it easier to reason about, esp. in terms of message-passing races e.g. with interrupts.Inputs are now returned synchronously to
ReadConsole()and represented by a newConsoleInputenum with variantsEOFandInput(String).The
R_ERROR_OCCURREDatomic and its friends are now simple variables inRMain.Some methods have been moved from
KerneltoRMainmethods. As discussed in Collect all global state for R callbacks in a struct #52, I would like to move all frontend methods toRMainin an ulterior PR, on the model of ffb6bbf. This way the methods can be written more conventionally with state inself, and we just need to make sure the unsafe dereferences of the globalR_MAINobject are indeed made from the R thread to ensure safety.For simplicity, the
StdInchannel is no longer passed via a specific message but is passed toKernel.connect()by argument. This channel is now owned byRMain.