# coding:utf-8
import gevent
import time
info = None # 定义数据
def product_handle():
global info
for item in range(10):
if item % 2 == 0:
info = "title = 小李老师、content = 软件技术讲师"
else:
info = "title = 沐言优拓、content = www.yootk.com"
print("【生产者】%s" % info)
gevent.sleep(1)
def consumer_handle():
while True:
print("【消费者】%s" % info)
gevent.sleep(1)
def main():
product_gevent = gevent.spawn(product_handle)
consumer_gevent = gevent.spawn(consumer_handle)
product_gevent.join()
consumer_gevent.join()
if __name__ == '__main__':
main()
网友评论