Guest User

Untitled

a guest
Apr 21st, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. import subprocess
  2. import multiprocessing as mp
  3.  
  4. def run(cmd):
  5. with open(cmd[-1], 'w') as f:
  6. return subprocess.run(cmd[:-1], stdout=f)
  7.  
  8. numbers = []
  9. i = 100000000
  10. for _ in range(10):
  11. numbers.append(i)
  12. i //= 2
  13.  
  14. commands = [['./a.out', str(x), str(x) + '.txt'] for x in numbers]
  15. nproc = 2
  16. pool = mp.Pool(nproc)
  17. pool.map(run, commands)
Add Comment
Please, Sign In to add comment