您好,我正在尝试将三重奏与两个异步函数和一条消息一起使用。但它并没有推出消费者,我真的不明白为什么。生产者在“队列”中发送良好,一旦饱和就不会发送任何内容。但消费者并不买账。还是我犯了一个错误?先感谢您
import time
import trio
async def producer(queue):
while True:
time.sleep(1)
if queue.full() is False:
queue.put_nowait(1)
print(queue.full())
print('put')
async def consumer(queue):
while True:
time.sleep(4)
if queue.full() is True:
print(queue.get_nowait())
print(queue.full())
print('get')
async def main():
queue = trio.Queue(capacity=4)
async with trio.open_nursery() as nursery:
# Two producers
nursery.start_soon(consumer, queue)
nursery.start_soon(producer, queue)
trio.run(main)