Advertisement
Guest User

Untitled

a guest
Aug 8th, 2014
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. import subprocess
  2. import os
  3. import pdb
  4.  
  5.  
  6. workers = 10
  7. ps = [subprocess.Popen(['python', 'processbf.py', str(workers), str(i)],
  8.                         stdout=subprocess.PIPE, close_fds=True) for i in range(workers)]
  9.  
  10. try:
  11.     os.remove("out.txt")
  12. except:
  13.     pass
  14.  
  15. mx = 0
  16. while workers>mx:
  17.     for p in ps[:]:
  18.         line = p.stdout.readline()
  19.         if line:
  20.             with open("out.txt", 'a') as fo:
  21.                 fo.write(line)
  22.         else:
  23.             mx+=1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement