Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何不使用 @parallel 装饰器在任务中并行化本地命令:
@parallel def myTask(): local('initialize localhost') run('command on remote host') local('clean up localhost')
我希望本地主机上的命令只执行一次,而远程主机的命令并行运行。现在我看到为每个远程主机实例运行本地主机命令。最干净的方法是什么?
谢谢
以下内容对您有用吗?
def local_init(): local('initialize') @parallel def myTask(): run('remote command') def local_cleanup(): local('clean up')
进而:
fab local_init myTask local_cleanup
将您的并行命令分组到一个装饰函数中。然后使用 execute() 在本地调用之间调用它。