title: Run different tasks in parallel on multiple hosts using Fabric/Python
body: <p>I have a python script using Fabric that I want to use to run customised versions of the same test on different hosts, this is done by connecting to those hosts remotely and then running a SSH command from there. </p>
  
  <p>Fabric easily lets you run tasks on multiple hosts but I cant find a way to run different tasks on different hosts at the same time:</p>
  
  <pre><code>from xml.dom import minidom
  import os, time
  from Config import *
  from subprocess import Popen
  
  env.source   = source
  env.file     = testRunFile
  env.set      = environmentSettings
  
  
  @hosts(remote1) 
  def rem1():
      env.user = user
      env.password = passw
      env.shell = tsch
  
  
      print ('%s' % remote1)
      print ('--------------------------------------------------')
      print ("%s REMOTE TEST" %(remote1))
      print ('--------------------------------------------------')
      print ('')
  
      with  prefix('setenv LD_LIBRARY_PATH'), prefix ('%s' %(env.set)), prefix("cd %s" % (env.source)) :
              run ("./%s '%s' -d %s  -v -j %s -%s %s dir=%s --target=myriad2" % (env.file, test_report, test_on1, proc1, opt_level1, test_timeouts1, staging_root))
  
              with prefix("cd ~walshs/WORK/Compilers/moviCompile/tests/reports"):
                  run ("python %s" % (test_file))
  </code></pre>