import timedef consumer(name): while True: print('老子%s准备吃包子啦!'%(name)) baozi = yield print('老子%s吃了第%s个包子了' %(name,baozi))def producer(name): print('你爹我%s准备做包子啦!' % name) a = consumer('xiaoming') b = consumer('zhangsan') a.__next__() b.__next__() for i in range(1,5): print('目前总共做了%s包子!' %(i*2)) time.sleep(2) b.send(i) a.send(i)producer('tianqiang')