下面是调用paramiko_ssh_machine并执行linux命令的测试用例。 没有多处理代码工作,但只要我启用多处理,python就会挂起并发现崩溃。
global file_handle
import os , sys
import paramiko_ssh_linux
import logging_path
import CFG
import multiprocessing
from datetime import datetime
file_handle= logging_path.log_result(sys.argv[0])
print "Output value returned ", file_handle
file_handle.write('My name is prince\n')
host='10.12.29.118'
host2='10.12.29.116'
##xecute the first command on the remote linux machine
cmd='uname -a'
cmd2="ifconfig -a"
list_cmd=[cmd , cmd2]
now=datetime.now()
print "STARTING TIME: " , now
for x in range(5):
process1=multiprocessing.Process(target=paramiko_ssh_linux.ssh_remote_machine,args=((file_handle,host,list_cmd),))
process2=multiprocessing.Process(target=paramiko_ssh_linux.ssh_remote_machine, args=((file_handle,host2,list_cmd),))
process1.start()
process2.start()
process1.join()
process2.join()
now=datetime.now()
print "ENDING TIME", now
#End the logging of the test case
logging_path.end_logging(file_handle)