Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.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 stdout.readlines()太慢_Python_Curl_Ssh_Paramiko - Fatal编程技术网

Python Paramiko stdout.readlines()太慢

Python Paramiko stdout.readlines()太慢,python,curl,ssh,paramiko,Python,Curl,Ssh,Paramiko,我在Python和Django代码中使用Paramiko来执行命令。这是我的密码: client = SSHClient() client.set_missing_host_key_policy(AutoAddPolicy()) client.connect(<host>, username=<username>, password=<password>) stdin, stdout, stderr = client.exec

我在Python和Django代码中使用Paramiko来执行命令。这是我的密码:

client = SSHClient()
client.set_missing_host_key_policy(AutoAddPolicy())
client.connect(<host>, username=<username>, password=<password>)
            
stdin, stdout, stderr =
    client.exec_command("curl -X POST http://127.0.0.1:8080/predictions -T image.jpg")
lines = stdout.readlines()
client=SSHClient()
客户端。设置\缺少\主机\密钥\策略(AutoAddPolicy())
client.connect(,用户名=,密码=)
标准输入,标准输出,标准输出=
client.exec_命令(“curl-X POSThttp://127.0.0.1:8080/predictions -T image.jpg)
lines=stdout.readlines()

对于每个命令,
stdout.readlines()
的执行时间为0.59秒。这对于我的接近实时的系统来说是不可接受的时间。有人能提出一些建议来加快阅读过程吗?

SSHClient.exec\u命令只启动该命令。它不会等待命令完成。这就是
readlines
所做的。因此,
readlines
所用的时间与命令所用的时间一样长


强制性警告:不要使用
AutoAddPolicy
–这样做会失去保护。有关正确的解决方案,请参阅