时间:2021-07-01 10:21:17 帮助过:146人阅读
1:参数 -P
from fabric.api import * host1 = 'root@ip1:22' host2 = 'root@ip2:22' env.hosts = [host1, host2 ] env.passwords = { host1: "p1", host2: "p2" } def backup_and_cp(): with cd("/home/**"): run('ls')
然后 运行 fab -P backup_and_cp就可以了
2:装饰器
import timefrom fabric.api import *host1 = 'root@ip1:22'host2 = 'root@ip2:22' env.hosts = [host1, host2 ] env.passwords = { host1: "p1", host2: "p2" } @parallel def backup_and_cp(): with cd("/home/**"): run('ls')
运行 fab backup_and_cp就OK了
以上就是fabric的两种并行方法代码的详细内容,更多请关注Gxl网其它相关文章!