Spur spawn不会将所有进程启动到远程计算机

时间:2018-04-26 09:30:18

标签: python ssh spawn

我使用spur(spawn)在远程计算机上启动大约20个进程。但有时它会全部启动,有时它会在20或20中启动。

有没有办法知道它为什么不启动?或任何其他方式一起启动脚本?

注意:我需要在启动后返回,我不必等待该过程在远程计算机上完成。

def spur_spawn(command,host,user,pwd,log):
        try:
                print "Command",command
                log.info("Command used on host : %s - > %s",host,command)
                if host == "local":

                        shell = spur.LocalShell()
                        result = shell.spawn(["sh", "-c", command],store_pid=True)

                else:
                        shell = spur.SshShell(hostname=host, username=user, password=pwd,shell_type=spur.ssh.ShellTypes.minimal,missing_host_key=spur.ssh.MissingHostKey.accept)
                        result = shell.spawn(["sh", "-c", command],allow_error=True)
                return result
        except Exception as e:
                import traceback
                log.error("Not able to launch job {} -> {}".format(e,host))
                s = traceback.format_exc()
                serr = "> stderr:\n%s\n" % (s)
                print serr
                logging.error("{}  -> {}".format(e,host))
                return 1,"",e

0 个答案:

没有答案