Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Главный процесс
- import os
- import subprocess
- import sys
- child = os.path.join(os.path.dirname(__file__), "./child.py")
- word = 'word'
- file = ['./parent.py','./child.py']
- pipes = []
- for i in range(0,2):
- command = [sys.executable, child]
- pipe = subprocess.Popen(command, stdin=subprocess.PIPE)
- pipes.append(pipe)
- pipe.stdin.write(word.encode("utf8") + b"\n")
- pipe.stdin.write(file[i].encode("utf8") + b"\n")
- pipe.stdin.close()
- while pipes:
- pipe = pipes.pop()
- pipe.wait()
- =====================================================================
- Сhild процесс
- import sys
- word = sys.stdin.readline().rstrip()
- filename = sys.stdin.readline().rstrip()
- try:
- with open(filename, "rb") as fh:
- while True:
- current = fh.readline()
- if not current:
- break
- if (word in current ):
- print("find: {0} {1}".format(filename,word))
- except :
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement