Thanks to visit codestin.com
Credit goes to github.com

Skip to content

SSH session automatically disconnects after parallel programming #50

@yaotianran

Description

@yaotianran

I want to know how much free memory on each node simultaneously. The code I run as following:

get.remote.free.mem <- function(ssh.session) {
      out <- ssh_exec_internal(ssh.session, command = c('cat /proc/meminfo'));
      mem = floor(as.numeric(stringr::str_extract(sys::as_text(out$stdout)[3], '\\d+'))/1024/1024);
      return(mem)
   }

# SSH.SESSION is a list, every item of which is a ssh session
free.mem.list = parallel::mclapply(SSH.SESSION,  get.remote.free.mem, mc.cores = length(SSH.SESSION))

I found that for this code mclapply can run normally only once. After I get the the free memory, re-running the last state (parallel::mclapply) will raise "Error: libssh failure at 'ssh_channel_open_session': Socket error: disconnected".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions