Error in summary.connection(connection) : invalid connection

I got this error because of an issue with the parallel computing back-end for foreach/dopar. You may have some parallel computing going on in the background that is not getting cleaned up fully between runs. The easiest way I have found to fix it is to call this function:

unregister_dopar <- function() {
  env <- foreach:::.foreachGlobals
  rm(list=ls(name=env), pos=env)
}

This function is from Steve Weston’s accepted answer in this thread: “un-register” a doParallel cluster

Leave a Comment