Bart Bart - 1 year ago 146
R Question

checking status of individual node of cluster created with parallel::makeCluster

Let's say I've created a cluster using:

cl <- parallel::makeCluster(2)
and I send a call to the first node using
parallel:::sendCall(cl[[1]], f, arg)

I want to get the results of a specific node (in this case the first node). I can do that using
. However, this process blocks until a result is received. Is there any way to check the status of of a specific node? I.e. a status like "is processing" or "is finished".

Answer Source

I'd recommend using the standard socketSelect function. For example:

cl <- makePSOCKcluster(3, outfile="")

# Send task to worker 1
x <- 2
parallel:::sendCall(cl[[1]], sqrt, list(x), tag=1)

# Wait up to 5 seconds for worker 1 to send the result back
ready <- socketSelect(list(cl[[1]]$con), timeout=5)

if (ready > 0) {
    result <- parallel:::recvData(cl[[1]])
    cat(sprintf("sqrt(%f) = %f\n", x, result$value))
} else {
    cat("result not ready after five seconds\n")

See the source for the recvOneData.SOCKcluster function in the file snowSOCK.R for a more complete example.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download