title: R doParallel foreach with error handling for independant workers
body: <p>I have to run a lot of random forest models so I want to use doParallel on my server with 8 cores to speed up the process.</p>
  
  <p>Yet, some models need a lot longer than others or even might throw errors. I would like to run 8 models in parallel, and if a model throws an error and/or is skipped then the workers should just continue. Each model result is saved on harddrive so I can access and combine them later.</p>
  
  <pre><code>TryCatch
  </code></pre>
  
  <p>or </p>
  
  <pre><code>.errorhandling="remove" 
  </code></pre>
  
  <p>did not solve the problem. I get</p>
  
  <pre><code> Error in unserialize(socklist[[n]]) : error reading from connection
  </code></pre>
  
  <p>Code example: I tried it with %do% and model 2-7 run successfully. Yet in %dopar% I get the shown error</p>
  
  <pre><code> foreach(model=1:8, .errorhandling="remove") %dopar% {
  
  
        tryCatch({
            outl &lt;- rf_perform(...)
            saveRDS(outl,file=getwd() %+% "/temp/result_" %+% model %+% ".rds")
  
       }, error = function(e) {print(e)}, finally = {})
    }
  </code></pre>