#encoding=utf-8
from multiprocessing import Process,Queue,Pipe
import time,os
q = Queue()
for i in range(11):
q.put(i)
def a():
for i in range(10):
num=q.get()
print '我是进程A,取出数字:%d'%num
def b():
for i in range(7):
num=q.get()
print '我是进程B,取出数字:%d'%num
def f(conn):
conn.send([42, None, 'hello'])
conn.close()
def m(conn):
conn.send([41, None, 'hail'])
conn.close()
def g(name):
print 'hello', name
if __name__ == '__main__':
p1=Process(target = a)
p2=Process(target = b)
p3 = Process(target=g, args=('bob',))
parent_conn, child_conn = Pipe()
p4 = Process(target=f, args=(child_conn,))
p5 = Process(target=m, args=(child_conn,))
p1.start()
p2.start()
p3.start()
p4.start()
p5.start()
print parent_conn.recv()
print parent_conn.recv()