python – Azure Service Bus message retrieval all have same lock times

I am having an issue retrieving messages off the Azure Service Bus using the python SDK, in respect to the lock times on the messages, but potentially it may be an issue with my understanding.

servicebus_client = ServiceBusClient.from_connection_string(connection_string)

sender = servicebus_client.get_queue_sender(queue_name)
receiver = servicebus_client.get_queue_receiver(

with servicebus_client, receiver, sender:
    while matching_messages < limit:
        received_messages = receiver.receive_messages(max_message_count=10)
        if not received_messages:

        for msg in received_messages:
            cprint(f"Processing SequenceNumber: {msg.sequence_number}, MessageId: {msg.message_id}", "light_blue")

I am creating a receiver, then using receive messages to retrieve messages in batches. Annoyingly I only ever seem to get 1 message back, even after messing with the max_message_count and prefetch_count, but this is a separate issue.

The issue is that the locked_until_utc time seems to be the same for every message I am retrieving from the service bus, and it seems to be based on the lock timeout + the time of first message

End of script error:

End of Script

Start of script:

Start of Script

At the start of the script however, there does seem to be a logical gap between the current time and the locked_until_utc, however this gets smaller and smaller as the lock time essentially gets stuck at a value. I would expect the locked_until_utc to get larger with each batch of messages retrieved, but this doesn’t seem to be happening.

Any idea would be appreciated.

Read more here: Source link