paleolimbot edited a comment 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. I think 
I have this working from other threads too but I'm too new to this to know 
exactly what I should be testing.
   
   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(
     function() "string one!",
     opt = "on_main_thread"
   )
   #> [1] "string one!"
   
   arrow:::TestSafeCallIntoR(
     function() stop("This is an error"),
     opt = "on_main_thread"
   )
   #> Error in (function () : This is an error
   
   arrow:::TestSafeCallIntoR(
     function() "string one!",
     opt = "async_with_executor"
   )
   #> [1] "string one!"
   
   # This runs with the expected error, but causes subsequent segfaults, 
probably related
   # to the error_token_ (maybe having to do with the copy-constructor?)
   
   # arrow:::TestSafeCallIntoR(
   #   function() stop("This is an error"),
   #   opt = "async_with_executor"
   # )
   
   arrow:::TestSafeCallIntoR(
     function() "string one!",
     opt = "async_without_executor"
   )
   #> Error: NotImplemented: Call to R from a non-R thread without an event loop
   ```
   


-- 
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]


Reply via email to