Advertisement
Guest User

Untitled

a guest
Jan 25th, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. import os
  2. import subprocess
  3. import sys
  4.  
  5.  
  6. child = os.path.join(os.path.dirname(__file__), "./child.py")
  7. word  = 'word'
  8. file = ['./parent.py','./child.py']
  9.  
  10. pipes = []
  11. for i in range(0,2):
  12.   command = [sys.executable, child]
  13.   pipe = subprocess.Popen(command, stdin=subprocess.PIPE)
  14.   pipes.append(pipe)
  15.   pipe.stdin.write(word.encode("utf8") + b"\n")
  16.   pipe.stdin.write(file[i].encode("utf8") + b"\n")
  17.   pipe.stdin.close()
  18.  
  19. while pipes:
  20.     pipe = pipes.pop()
  21.     pipe.wait()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement