#!/usr/bin/env python from multiprocessing import Process, Pipe import random import sys def evaluator(p): while True: stuff = p.recv() # evaluate the stuff if random.random() > 0.2: p.send("it's awesome!") else: p.send("it sucked!") if __name__ == '__main__': parent_conn, child_conn = Pipe() p = Process(target=evaluator, args=(child_conn,)) p.start() for x in sys.stdin: parent_conn.send(x) print parent_conn.recv()