from multiprocessing import Queue# 初始化一个队列, 可以设置大小, 如果队列已满超过的会等待队列有空位置q = Queue(3)q.put('消息 1')q.put('消息 2')q.put('消息 3')# 返回队列是否已满if not q.full():q.put('消息 4')else:print('队列已满')# 队列当前大小print(q.qsize())# 读取队列中的值并删除print(q.get())print(q.full())print(q.get())print(q.full())
