非阻塞RabbitMQ使用者-Python3

时间:2018-11-16 19:42:21

标签: python python-3.x asynchronous

我正在寻找用python3.7编写的最新的RabbitMQ使用者,该使用者可以并行处理消息。

我发现:

https://github.com/mosquito/aio-pikahttps://pika.readthedocs.io/en/0.12.0/examples/asyncio_consumer.html

仅当存在asyncio.sleep(1)时AIO-PIKA才能正常工作,但是我不明白为什么,如果我使用下面的示例(减去异步内容),那么asyncio_consumer示例将无法异步工作。< / p>

async def find_divisibles(inrange, div_by):
    print("finding nums in range {} divisible by {}".format(inrange, div_by))
    located = []
    for i in range(inrange):
        if i % div_by == 0:
            located.append(i)
        if i % 50000 == 0:
            await asyncio.sleep(0.0001)

    print("Done w/ nums in range {} divisible by {}".format(inrange, div_by))
    return located

(发件人:https://pythonprogramming.net/asyncio-basics-intermediate-python-tutorial/

0 个答案:

没有答案