Github user HyukjinKwon commented on the issue:
https://github.com/apache/spark/pull/18465
I rushed to read the comment. I also try to get rid of that try/catch in
c++ as below:
**R test alone**
```
vi tmp.R
```
copy and paste the codes in **Before** and **After** and then ran
```
Rscript tmp.R
```
Before
```R
library(Rcpp)
cppFunction('double takeLog(double val) {
throw std::range_error("Inadmissible value");
return NA_REAL; // not reached
}')
for(i in 0:10000) {
p <- parallel:::mcfork()
if (inherits(p, "masterProcess")) {
takeLog(-1.0)
print("unreachable")
tools::pskill(child, tools::SIGUSR1)
}
}
print("end")
Sys.sleep(10L)
```
After
```R
library(Rcpp)
cppFunction('double takeLog(double val) {
throw std::range_error("Inadmissible value");
return NA_REAL; // not reached
}')
for(i in 0:10000) {
p <- parallel:::mcfork()
if (inherits(p, "masterProcess")) {
takeLog(-1.0)
print("unreachable")
}
children <- suppressWarnings(parallel:::selectChildren(timeout = 0))
if (is.integer(children)) {
lapply(children, function(child) {
print(parallel:::readChild(child))
tools::pskill(child, tools::SIGUSR1)
})
}
}
print("end")
Sys.sleep(10L)
```
The symptoms are similar with
https://github.com/apache/spark/pull/18465#issuecomment-313049544
**End to end**
```
vi takeLog.cpp
```
copy and paste
```cpp
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
double takeLog(double val) {
throw std::range_error("Inadmissible value");
return NA_REAL; // not reached
}
```
With SparkR:
```R
func <- function(key, x) {
library(Rcpp)
path <-
"/Users/hyukjinkwon/Desktop/workspace/repos/forked/spark/takeLog.cpp"
sourceCpp(path)
takeLog(-1.0)
}
df <- createDataFrame(list(list(1L, 1, "1", 0.1)), c("a", "b", "c", "d"))
collect(gapply(df, "a", func, schema(df)))
# ... 30 times
collect(gapply(df, "a", function(key, x) { x }, schema(df)))
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]