python - mininet中的线程ping
问题描述
我想同时启动两台或多台主机,以便在 mininet 中使用 python 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 ...
"""
任何解决方案请...
解决方案
它通过在这一行中添加 args 来工作......
thread = threading.Thread(target=simpleTest, args=(hostsrc,hostdest,))
推荐阅读
- python - 获取数据帧 pandas 中数据时间的索引
- flutter - 如何将参数传递给 Riverpod 中的 ChangeNotifierProvider?
- r - 如何在rmarkdown中使用输入框和动作按钮输出本地图形
- python - 登录页面上的 Django-LDAP 身份验证
- reactjs - 将 localStorage.getItem() 与打字稿一起使用
- android - 无法点击 FAB 按钮的下半部分(与 CustomBottomNavigationBar 结合使用)
- javascript - Babel 忽略 IE6 目标?
- python - 如何使用open cv python计算水平线的数量?
- php - 正则表达式匹配字符串的不同变体?
- r - 通过厨师距离和 lm 模型去除异常值