0

Running this call to parLapply

cl <- makeCluster(n_division)

parLapply(cl,
      seq(1, 22),

      function(indice){
        data <- readRDS("data.rds")
        liste <- unique(data$identif)
        lapply(liste,
                 function(id){
                   print(id)
                   df_id <- data %>%
                     filter(identif == id)
                   name_file <- "result.rds"
                   tryCatch({
                       result_df <<- MYFUNCTION(df_id)  ==> **This function return ERROR**
                       saveRDS(result_df , name_file )
                    }, error = function(err){
                       log_message(err)
                    })
                 }
             )
 })

stopCluster(cl)

produces this error

22 nodes produced errors; first error: all connections are in use

Calls: source ... clusterApply -> staticClusterApply -> checkForRemoteErrors

Execution halted

someone already had the same error ?

Community
  • 1
  • 1
  • 1
    Hi, you may want to create a [minimal reproducible example](https://stackoverflow.com/a/5963610/2414988) so that we can help you. Without more information, all we can tell is that connections (to a file maybe?) created in the function given to `parlapply` are failing. – Biblot Oct 21 '19 at 13:16
  • You ever figure this out? – kputschko Aug 01 '22 at 12:48

1 Answers1

0
cl <- makeCluster(n_division)

parLapply(cl,
          seq(1, 22),

          function(indice){
            data <- readRDS("data.rds")
            liste <- unique(data$identif)
            lapply(liste ,
                     function(id){
                       print(id)
                       df_id <- data %>%
                         filter(identif == id)
                       name_file <- "result.rds"
                       tryCatch({
                           result_df <<- MYFUNCTION(df_id)  ==> **This function return ERROR**
                           saveRDS(result_df , name_file )
                        }, error = function(err){
                           log_message(err)
                        })
             }
                 )
 })

stopCluster(cl)
  • Please add your example code to your question by editing your post. You should not post it as an answer. You should also describe what your input is, provide a sample dataset, describe your goal and provide an example output. See the link in my other comment for examples on how to write a good question on SO. – Biblot Oct 21 '19 at 14:35