Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python paramiko.SSHClient.exec_命令挂起_Python_Python 3.x_Ssh_Exec_Paramiko - Fatal编程技术网

Python paramiko.SSHClient.exec_命令挂起

Python paramiko.SSHClient.exec_命令挂起,python,python-3.x,ssh,exec,paramiko,Python,Python 3.x,Ssh,Exec,Paramiko,我只需要在远程服务器上启动另一个Python脚本(例如:second\u Python.py)。这个second_python.py将等待来自其他服务器的请求。所以只需要启动start_python.py并返回到第一个python脚本并继续。我使用了下面的脚本,但在启动第二个\u python.py后,脚本挂起 #First python script import es_helper def ConnectES(self,payload_script): self.es = es_helpe

我只需要在远程服务器上启动另一个Python脚本(例如:
second\u Python.py
)。这个
second_python.py
将等待来自其他服务器的请求。所以只需要启动
start_python.py
并返回到第一个python脚本并继续。我使用了下面的脚本,但在启动
第二个\u python.py
后,脚本挂起

#First python script
import es_helper
def ConnectES(self,payload_script):
 self.es = es_helper.ESHelper(config.es_ip)      
 self.es.execute_script(config.es_script_path,config.es_script,payload_script)

#es_helper.py
def execute_command(self, cmd):
  LOG.debug("executing command '{}'".format(cmd))
  stdin, stdout, stderr = self.ssh_client.exec_command(cmd)
  return stdout.readlines(), stderr.readlines()

#This function used to start second python script
def execute_script(self,es_script_path,es_script,payload_script):
  self.execute_command('python {0}{1}{2} {0}{1}{3} > {0}{1}1.txt'.format(es_script_path,'/',es_script,es_script))


#client.py
def exec_command(
    self,
    command,
    bufsize=-1,
    timeout=None,
    get_pty=False,
    environment=None,
):

    chan = self._transport.open_session(timeout=timeout)
    if get_pty:
        chan.get_pty()
    chan.settimeout(timeout)
    if environment:
        chan.update_environment(environment)
    chan.exec_command(command)
    stdin = chan.makefile("wb", bufsize)
    stdout = chan.makefile("r", bufsize)
    stderr = chan.makefile_stderr("r", bufsize)
    return stdin, stdout, stderr

预期结果:启动第二个python脚本并返回到第一个python脚本,
readlines
等待命令完成。如果不想等待,请取消呼叫