#_author:来童星
#date:2019/12/12
def consumer(name):
print("--->start...")
while True:
new_baozi = yield
print("[%s] is eating baozi %s" % (name, new_baozi))
# time.sleep(1)
def producer():
next(con)
next(con2)
n = 0
while n < 5:
n += 1
print("\033[32;1m[producer]\033[0m is making baozi %s" % n)
con.send(n)
con2.send(n) if __name__ == '__main__':
con = consumer("c1")# 创建一个生成器对象
con2 = consumer("c2")# 创建一个生成器对象
p = producer()# 执行producer()方法,p为方法返回值