paleolimbot commented on pull request #12558:
URL: https://github.com/apache/arrow/pull/12558#issuecomment-1079223791
Redoing this with an eye towards where I would actually like to use it! I
think that it does need a synchronous `Status<cpp_type>
SafeCallIntoR<cpp_type>([]() { return r_api_call(); })`, even if all the
synchronous version does is error when it's not safe to execute R code. A
`SafeCallIntoRAsync()` would also be useful but I'm not sure of the details of
how to implement it.
The places where I would prefer to use this in some other PRs:
-
https://github.com/apache/arrow/pull/12467/files#diff-b3e736a08e6e6823de704595b9204a1a9907f75c639d32c50cf7b4a79f3e3153R103-R108
-
https://github.com/apache/arrow/pull/12467/files#diff-b3e736a08e6e6823de704595b9204a1a9907f75c639d32c50cf7b4a79f3e3153R144-R146
-
https://github.com/apache/arrow/pull/12323/files#diff-e518a9483c6cdc0c05e79d7ebe59539a3107cd47bb6312d431a83d9d8555a3a9R248-R313
Some sketch examples:
``` r
arrow:::TestSafeCallIntoR(
list(
function() "string one",
function() "string two"
),
async = FALSE
)
#> [1] "string one" "string two"
arrow:::TestSafeCallIntoR(
list(
function() stop("This is an error!")
),
async = FALSE
)
#> Error in (function () : This is an error!
arrow:::TestSafeCallIntoR(
list(
function() "string one",
function() "string two"
),
async = TRUE
)
#> Error: NotImplemented: Call to R from a non-R thread
arrow:::TestSafeCallIntoR(
list(
function() stop("This is an error!")
),
async = TRUE
)
#> Error: NotImplemented: Call to R from a non-R thread
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]