Created
June 27, 2015 17:42
-
-
Save MarkLavrynenko/02711dc9c16242afd96f to your computer and use it in GitHub Desktop.
Revisions
-
MarkLavrynenko created this gist
Jun 27, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ from multiprocessing import Pool, Pipe, Process def work(process_name, pipe): while True: print("%s Start w8!" % process_name) data = pipe.recv() print("%s You sent %s" % (process_name, data)) if __name__ == "__main__": parent, child = Pipe() p1 = Process(target=work, args=("P1", child,)) p1.start() p2 = Process(target=work, args=("P2", child,)) p2.start() while True: try: data = raw_input() parent.send(data) except KeyboardInterrupt: print("On KeyboardInterrupt") child.close() parent.close() exit(0)