Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # PARENT
- import subprocess
- import sys
- test = "./child.py"
- process = subprocess.Popen(test, shell=True,
- stdin=subprocess.PIPE, stdout=subprocess.PIPE)
- for i in range(1000):
- process.stdin.write("%d\n" % (i,))
- process.stdin.flush()
- output = process.stdout.readline()
- print "OUTPUT =", output.strip()
- process.stdin.close()
- process.wait()
- #!/usr/bin/env python
- # CHILD
- import sys
- while True:
- line = sys.stdin.readline()
- if not line:
- break
- number = int(line)
- sys.stdout.write("%d\n" % (number ** 2,))
- sys.stdout.flush()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement