question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Azure Storage Queue] receive_messages infinite loop

See original GitHub issue
  • Package Name:
  • Package Version:
  • Operating System:
  • Python Version:

Describe the bug It is not a bug, more like really unexpected behavior.

https://github.com/Azure/azure-sdk-for-python/blob/1ca37b47d156ed76922835e7097ee55396bf2fc5/sdk/storage/azure-storage-queue/azure/storage/queue/_queue_client.py#L546

Azure Storage Queue receive_messages doesn’t have a way to define maximum number of messages to receive. If it is ever used against the queue that constantly gets new messages, it will just stuck in an infinite loop because it will try to query extra messages.

If it runs in a serverless environment, where execution is limited by time, it will lead to potential data loss when function is killed.

There is a workaround for this, but it is not obvious from the method description that it will continuously look for messages instead of dequeuing all available or X…

messages = queue_service.receive_messages()

try:
    return [m for m in messages.by_page().next()]
except StopIteration:
    return []

To Reproduce Steps to reproduce the behavior: 1.

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
amishra-devcommented, Dec 1, 2021
0reactions
jalauzon-msftcommented, Mar 1, 2022

@amishra-dev, it looks like this needs more investigation to come up with the right solution. I will investigate.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure's QueueClient.ReceiveMessagesAsync returns when ...
ReceiveMessagesAsync simply makes an HTTP request to the blob-storage queue every time you call it. There is no mechanism in the Azure.Storage.
Read more >
QueueClient.ReceiveMessages Method - Microsoft Learn
Receives one or more messages from the front of the queue. For more information, see Get Messages.
Read more >
Unable to receive some messages from Service Bus Queue
My scenario is, I have an Azure Function which is using Event Hub trigger. After processing data from Event Hub, I am saving...
Read more >
Service Bus - Connectors - Microsoft Learn
Connect to Azure Service Bus to send and receive messages. ... This combination can create an infinite loop, which results in a workflow...
Read more >
How to use Azure Queue Storage from Python - Microsoft Learn
Storage Account: All access to Azure Storage is done through a storage account. · Queue: A queue contains a set of messages. ·...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found