Remove zombie processes using parallel package

本小妞迷上赌 提交于 2019-11-30 11:18:20

This only seems to be an issue with "FORK" clusters. If you make a "PSOCK" cluster instead, the processes will die when you call stopCluster(cl).

Is there anything preventing you from using a "PSOCK" cluster on your Debian-based machine?

Probably the answer of your problem is in the help file of makeCluster() command.

At the bottom of the file, it is written : It is good practice to shut down the workers by calling stopCluster: however the workers will terminate themselves once the socket on which they are listening for commands becomes unavailable, which it should if the master R session is completed (or its process dies).

The solution is (it is working for me) to define a port for your cluster while you are creating it.

cl <- makeCluster(2, type = cltype,port=yourPortNumber)

another (may be not usefull) solution is setting a timeout for your sockets. timeout variable is in seconds.

cl <- makeCluster(2, type = cltype,port=yourPortNumber,timeout=50)

In any case, the aim should be to make the socket connection unavailable.either closing the ports or closing the main R process would do this.

Edit: What I meant was to close the ports which the process is listening. It should be OS independent. you can try to use -> showConnections(all = TRUE); . This will give all the connections. Then you can try closeAllConnections();

Sorry if this doesn't work also.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!