【发布时间】:2021-02-22 07:27:57
【问题描述】:
我正在尝试使用 python azure.storage.queue 库向 azure 发送大量消息(数千万),但是这样做需要很长时间。我使用的代码如下:
from azure.storage.queue import (
QueueClient,
BinaryBase64EncodePolicy,
BinaryBase64DecodePolicy
)
messages = [example list of messages]
connectionString = "example connection string"
queueName = "example-queue-name"
queueClient = QueueClient.from_connection_string(connectionString, queueName)
for message in messages:
queueClient.send_message(message)
目前,发送大约 70,000 条消息需要大约 3 个小时,考虑到需要发送的潜在消息数量,这显然太慢了。
我查看了文档以尝试找到批处理选项,但似乎不存在:https://docs.microsoft.com/en-us/python/api/azure-storage-queue/azure.storage.queue.queueclient?view=azure-python
我还想知道是否有人有任何使用 asynchio 库来加快此过程的经验并可以建议如何使用它?
【问题讨论】:
-
怎么样?我的帖子有用吗?
标签: python azure python-asyncio azure-queues