Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WISH: killNode() for 'cluster' #33

Closed
HenrikBengtsson opened this issue Nov 9, 2020 · 2 comments
Closed

WISH: killNode() for 'cluster' #33

HenrikBengtsson opened this issue Nov 9, 2020 · 2 comments
Milestone

Comments

@HenrikBengtsson
Copy link
Owner

HenrikBengtsson commented Nov 9, 2020

Add S3 methods psKill() for cluster to send a signal to the cluster node R process, e.g.

> cl <- parallelly::makeClusterPSOCK(4L)
> isAlive(cl)
[1] TRUE TRUE TRUE TRUE
> psKill(cl[2:3], signal = tools::SIGINT)
> Sys.sleep(10)
> isAlive(cl)
[1] TRUE FALSE FALSE TRUE

For localhost workers, we can use tools::pskill(pid, signal = ...). For remote ones, we need to call pskill -SIG $PID over a remote connection.

This will allow us to terminate stalled workers and set up new ones, e.g.

> alive <- isAlive(cl)
> if (!all(alive)) cl <- c(cl[alive], makeClusterPSOCK(length(cl) - sum(!alive))) 
> isAlive(cl)
[1] TRUE TRUE TRUE TRUE
HenrikBengtsson added a commit that referenced this issue Dec 3, 2022
HenrikBengtsson added a commit that referenced this issue Dec 3, 2022
HenrikBengtsson added a commit that referenced this issue Dec 3, 2022
HenrikBengtsson added a commit that referenced this issue Dec 3, 2022
…use of a bug in tools::pskill() that was fixed later [#33]
@HenrikBengtsson HenrikBengtsson changed the title WISH: psKill() for 'cluster' WISH: killNode() for 'cluster' Dec 3, 2022
@HenrikBengtsson
Copy link
Owner Author

Implemented in develop branch;

> library(parallelly)
> cl <- makeClusterPSOCK(4L)
> isNodeAlive(cl)
[1] TRUE TRUE TRUE TRUE
> killNode(cl[2:3])
[1] TRUE TRUE
> isNodeAlive(cl)
[1]  TRUE FALSE FALSE  TRUE
> killNode(cl)
[1]  TRUE FALSE FALSE  TRUE
> isNodeAlive(cl)
[1] FALSE FALSE FALSE FALSE

@HenrikBengtsson
Copy link
Owner Author

BTW, this requires that we have collected the process ID:s for the workers, which is only done by makeClusterPSOCK(), but not by parallel;

> cl <- parallel::makePSOCKcluster(4L)
TRACKER: .GlobalEnv changed: 1 variable added ('.Last.condition')
> isNodeAlive(cl)
[1] NA NA NA NA
> killNode(cl)
[1] NA NA NA NA
Warning messages:
1: In killNode.default(X[[i]], ...) :
  killNode() is not supported for 'SOCKnode' objects. Signal 15 was not sent
Calls: killNode ... killNode.cluster -> vapply -> FUN -> killNode.default
2: In killNode.default(X[[i]], ...) :
  killNode() is not supported for 'SOCKnode' objects. Signal 15 was not sent
Calls: killNode ... killNode.cluster -> vapply -> FUN -> killNode.default
3: In killNode.default(X[[i]], ...) :
  killNode() is not supported for 'SOCKnode' objects. Signal 15 was not sent
Calls: killNode ... killNode.cluster -> vapply -> FUN -> killNode.default
4: In killNode.default(X[[i]], ...) :
  killNode() is not supported for 'SOCKnode' objects. Signal 15 was not sent
Calls: killNode ... killNode.cluster -> vapply -> FUN -> killNode.default

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant