Folks,

I guess I know what is going on (and why I haven't seen this so far): All of you have installed R in a directory with blanks in it, right?

Please source() the attached sock.R and afterwards try again. Does it work with SOCK clusters now? Then it was just the lack of quotes.

CCing Luke the diffs (against snow 0.3-3 on CRAN):

@@ -29,8 +29,8 @@
             env <- paste("MASTER=", master,
                          " PORT=", port,
                          " OUT=", outfile,
-                         " SNOWLIB=", snowlib, sep="")
-            cmd <- paste(rscript, script, env)
+                         " SNOWLIB=", shQuote(snowlib), sep="")
+            cmd <- paste(shQuote(rscript), shQuote(script), env)
         }
         else {
             script <- "RunSnowWorker RSOCKnode.R"
@@ -43,13 +43,13 @@
     else {
         if (homogeneous) {
             scriptdir <- getClusterOption("scriptdir", options)
-            script <- file.path(scriptdir, "RSOCKnode.sh")
+            script <- shQuote(file.path(scriptdir, "RSOCKnode.sh"))
rlibs <- paste(getClusterOption("rlibs", options), collapse = ":")
             rprog <- getClusterOption("rprog", options)
             env <- paste("MASTER=", master,
                          " PORT=", port,
                          " OUT=", outfile,
-                         " RPROG=", rprog,
+                         " RPROG=", shQuote(rprog),
                          " R_LIBS=", rlibs, sep="")
         }
         else {


(same problem in mpi.R, nws.R etc. as well, I think)

Best wishes,
Uwe









On 16.05.2011 00:01, David Anisman wrote:
Same problem as Anna here.

Windows 7 64-bit. Running R 2.13.0. snow + snowfall installed.

Testing:

library(snow)
library(snowfall)

sfInit(parallel=TRUE, cpus=2, type="SOCK")

Then R spins forever (yes, I disabled the Windows firewall).

On the same box, tried the same on Ubuntu under Virtualbox. No problem. Runs
well.

Any suggestions/ideas appreciated.


David



--
View this message in context: 
http://r.789695.n4.nabble.com/Snow-Snowfall-hangs-on-windows-7-tp3436724p3524990.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
#
# Socket Implementation
#

#**** allow user to be different on different machines
#**** allow machines to be selected from a hosts list
newSOCKnode <- function(machine = "localhost", ...,
                        options = defaultClusterOptions) {
    # **** allow some form of spec here
    # **** make sure options are quoted
    options <- addClusterOptions(options, list(...))
    if (is.list(machine)) {
        options <- addClusterOptions(options, machine)
        machine <- machine$host
    }
    outfile <- getClusterOption("outfile", options)
    if (machine == "localhost") master <- "localhost"
    else master <- getClusterOption("master", options)
    port <- getClusterOption("port", options)
    manual <- getClusterOption("manual", options)

    ## build the local command for starting the worker
    homogeneous <- getClusterOption("homogeneous", options)
    if (getClusterOption("useRscript", options)) {
        if (homogeneous) {
            rscript <- getClusterOption("rscript", options)
            snowlib <- getClusterOption("snowlib", options)
            script <- file.path(snowlib, "snow", "RSOCKnode.R")
            env <- paste("MASTER=", master,
                         " PORT=", port,
                         " OUT=", outfile,
                         " SNOWLIB=", snowlib, sep="")
            cmd <- paste(rscript, script, env)
        }
        else {
            script <- "RunSnowWorker RSOCKnode.R"
            env <- paste("MASTER=", master,
                         " PORT=", port,
                         " OUT=", outfile, sep="")
            cmd <- paste(script, env)
        }
    }
    else {
        if (homogeneous) {
            scriptdir <- getClusterOption("scriptdir", options)
            script <- file.path(scriptdir, "RSOCKnode.sh")
            rlibs <- paste(getClusterOption("rlibs", options), collapse = ":")
            rprog <- getClusterOption("rprog", options)
            env <- paste("MASTER=", master,
                         " PORT=", port,
                         " OUT=", outfile,
                         " RPROG=", rprog,
                         " R_LIBS=", rlibs, sep="")
        }
        else {
            script <- "RunSnowNode RSOCKnode.sh"
            env <- paste("MASTER=", master,
                         " PORT=", port,
                         " OUT=", outfile, sep="")
        }
        cmd <- paste("env", env, script)
    }

    if (manual) {
        cat("Manually start worker on", machine, "with\n    ", cmd, "\n")
        flush.console()
    }
    else {
        ## add the remote shell command if needed
        if (machine != "localhost") {
            rshcmd <- getClusterOption("rshcmd", options)
            user <- getClusterOption("user", options)
            cmd <- paste(rshcmd, "-l", user, machine, cmd)
        }

        if (.Platform$OS.type == "windows") {
            ## On windows using input = something seems needed to
            ## disconnect standard input of an ssh process when run
            ## from Rterm (at least using putty's plink).  In
            ## principle this could also be used for supplying a
            ## password, but that is probably a bad idea. So, for now
            ## at least, on windows password-less authentication is
            ## necessary.
            system(cmd, wait = FALSE, input = "")
        }
        else system(cmd, wait = FALSE)
    }
    
    
    ## need timeout here because of the way internals work
    timeout <- getClusterOption("timeout")
    old <- options(timeout = timeout);
    on.exit(options(old))
    con <- socketConnection(port = port, server=TRUE, blocking=TRUE,
                            open="a+b")
    structure(list(con = con, host = machine), class = "SOCKnode")
}

makeSOCKmaster <- function(master = Sys.getenv("MASTER"),
                           port = Sys.getenv("PORT")) {
    port <- as.integer(port)
    ## maybe use `try' and sleep/retry if first time fails?
    ## need timeout here because of the way internals work
    timeout <- getClusterOption("timeout")
    old <- options(timeout = timeout);
    on.exit(options(old))
    con <- socketConnection(master, port = port, blocking=TRUE, open="a+b")
    structure(list(con = con), class = "SOCKnode")
}

closeNode.SOCKnode <- function(node) close(node$con)

sendData.SOCKnode <- function(node, data) {
##     timeout <- getClusterOption("timeout")
##     old <- options(timeout = timeout);
##     on.exit(options(old))
    serialize(data, node$con)
}

recvData.SOCKnode <- function(node) {
##     timeout <- getClusterOption("timeout")
##     old <- options(timeout = timeout);
##     on.exit(options(old))
    unserialize(node$con)
}

recvOneData.SOCKcluster <- function(cl) {
    socklist <- lapply(cl, function(x) x$con)
    repeat {
        ready <- socketSelect(socklist)
        if (length(ready) > 0) break;
    }
    n <- which(ready)[1]  # may need rotation or some such for fairness
    list(node = n, value = unserialize(socklist[[n]]))
}

makeSOCKcluster <- function(names, ..., options = defaultClusterOptions) {
    if (is.numeric(names))
        names <- rep('localhost', names[1])
    options <- addClusterOptions(options, list(...))
    cl <- vector("list",length(names))
    for (i in seq(along=cl))
        cl[[i]] <- newSOCKnode(names[[i]], options = options)
    class(cl) <- c("SOCKcluster", "cluster")
    cl
}
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to