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

SSH session automatically disconnects after parallel programming #50

Open
yaotianran opened this issue Jul 24, 2021 · 0 comments
Open

Comments

@yaotianran
Copy link

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".

@yaotianran yaotianran changed the title SSH session automatically disconnect after parallel programming SSH session automatically disconnects after parallel programming Jul 24, 2021
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