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

AsyncBackend does not bubble up errors to main session #35

Closed
mihaiconstantin opened this issue May 6, 2023 · 1 comment · Fixed by #38
Closed

AsyncBackend does not bubble up errors to main session #35

mihaiconstantin opened this issue May 6, 2023 · 1 comment · Fixed by #38
Assignees
Labels
bug Something isn't working

Comments

@mihaiconstantin
Copy link
Owner

The following code shows that when the task execution results in an error, that error is not bubbled up to the main session. Instead, the expected behavior should be throwing the error in the main session to make the users aware that something went wrong.

# Creat e specification instance.
specification <- Specification$new()

# Select cores and type.
specification$set_cores(4)
specification$set_type("psock")

# Create an asynchronous backend instance.
backend <- AsyncBackend$new()

# Start the backend.
backend$start(specification)

# Run a task.
backend$sapply(1:10, function(x) x + 1)

# Get the output.
backend$get_output(wait = TRUE)

# Run a task that throws an error.
backend$sapply(1:10, function(x) stop("Some unexpected error."))

# Get the output.
backend$get_output(wait = TRUE)

# Stop the backend.
backend$stop()

This is not the case for the SyncBackend class.

# Create a synchronous backend instance.
backend <- SyncBackend$new()

# Start the backend.
backend$start(specification)

# Run a task that throws an error.
backend$sapply(1:10, function(x) stop("Some unexpected error."))

# Stop the backend.
backend$stop()

Perhaps, in AsyncBackend, instead of setting the .output field right away (i.e., see below), we could first check to see if the session encountered errors and, if so, raise them to the main session.

parabar/R/AsyncBackend.R

Lines 249 to 253 in 6880ebc

# Set the output based on the session read.
.set_output = function() {
# Store the relevant results from the output.
private$.output <- private$.cluster$read()$result
},

@mihaiconstantin mihaiconstantin added the bug Something isn't working label May 6, 2023
@mihaiconstantin mihaiconstantin self-assigned this May 6, 2023
@mihaiconstantin
Copy link
Owner Author

Or, we could also set the error to the .output field—not sure which makes more sense.

mihaiconstantin added a commit that referenced this issue May 7, 2023
Fix silent errors during task execution in`AsyncBackend`. Closes #35.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant