You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the parent session of a PSOCK cluster terminates without properly shutting down the cluster first, the workers will (i) keep running, and (ii) eventually produce an error due to a broken connection:
$ R --vanilla
> cl <- parallelly::makeClusterPSOCK(1L, outfile='')
> quit('no')
starting worker pid=27586 on localhost:11470 at 20:15:04.478
Error in unserialize(node$con) : error reading from connection
Calls: workRSOCK ... doTryCatch -> recvData -> recvData.SOCKnode -> unserialize
$
Idea
We could set up an "on-session-exit" function that will be called when R terminates. Here's a proof of concept:
There is a major downside with this idea; depending how busy the workers are, it might take s very long time before the main R session can terminate. It might require a user interrupt or a timeout
That's a neat trick. Should probably investigate and update the quite-old R.utils::onSessionExit() to do that instead and avoid the whole .Last() hack. Thxs
If the parent session of a PSOCK cluster terminates without properly shutting down the cluster first, the workers will (i) keep running, and (ii) eventually produce an error due to a broken connection:
Idea
We could set up an "on-session-exit" function that will be called when R terminates. Here's a proof of concept:
The
onSessionExit()
function of R.utils works by injecting/updating a.Last()
function, which will be called when callingquit(..., runLast = TRUE)
which is the default. BTW, it looks like there's a bug in R.utils causing this to only work if R.utils is attached - it's not sufficient to just loading, e.g.R.utils::onSessionExit()
won't do.Here is the same example when running in non-interactive mode;
and
The text was updated successfully, but these errors were encountered: