我想同时启动两个或多个主机,用python在mininet中ping另外两个主机,我这样做了,但不起作用
def simpleTest(h1,h2):
print (h1.cmd('ping -c5 %s' h2.IP()))
主要内容:
if __name__ == '__main__':
net = Mininet(...)
threads= 3 # three threads
#....codes......
for i in range(1, threads):
hostsrc=net.hosts[i]
hostdest=net.hosts[i+4]
thread = threading.Thread(target=simpleTest(hostsrc,hostdest))
jobs.append(thread)
for j in jobs:
j.start()
for j in jobs:
j.join()
"""
codes ...
"""
有什么解决办法吗。。。你知道吗
它通过在这行中添加参数来工作。。。你知道吗
问题是,当您将
simpleTest
函数作为参数传递时,您正在调用它。您应该这样编写代码:或使用lambda:
您编写的代码将值None传递给
target
参数,因为simpleTest
函数不返回值,所以调用start
方法时没有发生任何事情。你知道吗相关问题 更多 >
编程相关推荐