[Service Bus] Clarify prefetch_count versus max_message_count docstrings - #48464
Draft
Eldert Grootenboer (EldertGrootenboer) wants to merge 4 commits into
Draft
[Service Bus] Clarify prefetch_count versus max_message_count docstrings#48464Eldert Grootenboer (EldertGrootenboer) wants to merge 4 commits into
Eldert Grootenboer (EldertGrootenboer) wants to merge 4 commits into
Conversation
The prefetch_count docstring described the setting as the maximum number of messages to cache, while a following sentence said that at a prefetch_count of 0 receive_messages caches max_message_count within its request. Reusing cache for both a standing buffer and a per-call request made the two settings read as one. prefetch_count is now described as what the receiver requests ahead of a receive call, and each site states that it is separate from the max_message_count argument. receive_messages explains how the two interact at and above the default, and documents that passing None falls back to prefetch_count and so returns an empty list at the default. Fixes #42697.
Eldert Grootenboer (EldertGrootenboer)
requested a balanced review from Copilot
August 5, 2026 23:22
Copilot started reviewing on behalf of
Eldert Grootenboer (EldertGrootenboer)
August 5, 2026 23:22
View session
|
Azure Pipelines: Successfully started running 1 pipeline(s). 10 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
Clarifies Service Bus receiver documentation for prefetch_count, max_message_count, and max_wait_time.
Changes:
- Distinguishes prefetch buffering from per-call batch limits.
- Documents default and
Nonebehavior. - Updates synchronous and asynchronous APIs consistently.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
_servicebus_receiver.py |
Updates synchronous receiver docstrings. |
_servicebus_client.py |
Clarifies synchronous receiver factory parameters. |
aio/_servicebus_receiver_async.py |
Updates asynchronous receiver docstrings. |
aio/_servicebus_client_async.py |
Clarifies asynchronous receiver factory parameters. |
Suppressed comments (2)
sdk/servicebus/azure-servicebus/azure/servicebus/_servicebus_receiver.py:635
- The new guard only scopes the no-timeout sentence. The following “If specified” sentence still says that a call with any timeout waits for that timeout, contradicting the documented
max_message_count=None/prefetch_count=0path. Carry the “messages are requested” condition across both cases.
If messages are requested, no messages arrive, and no timeout is specified, this call will not
return until the connection is closed. If specified, and no messages arrive within the
timeout period, an empty list will be returned. NOTE: Setting max_wait_time on receive_messages
sdk/servicebus/azure-servicebus/azure/servicebus/aio/_servicebus_receiver_async.py:624
- The new guard only scopes the no-timeout sentence. The following “If specified” sentence still says that a call with any timeout waits for that timeout, contradicting the documented
max_message_count=None/prefetch_count=0path. Carry the “messages are requested” condition across both cases.
If messages are requested, no messages arrive, and no timeout is specified, this call will not
return until the connection is closed. If specified, and no messages arrive within the
timeout period, an empty list will be returned. NOTE: Setting max_wait_time on receive_messages
_receive opens the AMQP receiver before resolving None to a zero count, so a first call on an unopened receiver connects and authenticates before returning. Say the call returns without waiting for messages rather than immediately, which read as a latency guarantee.
Eldert Grootenboer (EldertGrootenboer)
requested a balanced review from Copilot
August 5, 2026 23:43
Copilot started reviewing on behalf of
Eldert Grootenboer (EldertGrootenboer)
August 5, 2026 23:44
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (2)
sdk/servicebus/azure-servicebus/azure/servicebus/_servicebus_receiver.py:621
- At
prefetch_count == 0, the receiver can already hold one RECEIVE_AND_DELETE message from its standing link credit._receivedrains that buffer first and grants credit only formax_message_count - len(batch), so this call can request fewer thanmax_message_countmessages from the service. Describemax_message_countas the call target and the service request as only the additional messages needed.
the same one. When `prefetch_count` is 0, the receiver requests `max_message_count` (if
provided) messages from the service on this call. When `prefetch_count` is greater than 0,
the call is served first from what the receiver already holds, and if that is fewer than
`max_message_count` it continues receiving on the receiver's standing prefetch credit until
the count is met or the wait time elapses.
sdk/servicebus/azure-servicebus/azure/servicebus/aio/_servicebus_receiver_async.py:610
- At
prefetch_count == 0, the receiver can already hold one RECEIVE_AND_DELETE message from its standing link credit._receivedrains that buffer first and grants credit only formax_message_count - len(batch), so this call can request fewer thanmax_message_countmessages from the service. Describemax_message_countas the call target and the service request as only the additional messages needed.
the same one. When `prefetch_count` is 0, the receiver requests `max_message_count` (if
provided) messages from the service on this call. When `prefetch_count` is greater than 0,
the call is served first from what the receiver already holds, and if that is fewer than
`max_message_count` it continues receiving on the receiver's standing prefetch credit until
the count is met or the wait time elapses.
Addresses review feedback on the receive_messages docstring. Scopes the requests claim to the call, since the link holds one standing credit even at prefetch_count 0, and uses one vocabulary for the None condition.
Eldert Grootenboer (EldertGrootenboer)
requested a balanced review from Copilot
August 6, 2026 04:04
Copilot started reviewing on behalf of
Eldert Grootenboer (EldertGrootenboer)
August 6, 2026 04:05
View session
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #42697.
The
prefetch_countdocstring described the setting as "the maximum number ofmessages to cache", while a following sentence said that at a
prefetch_countof 0,
receive_messages"would try to cachemax_message_count(if provided)within its request to the service". Using "cache" for both a standing buffer and
a per-call request is what made the two settings read as one, which is exactly
what the issue asks about.
Changes
prefetch_countis now described as the number of messages the receiverrequests ahead of a receive call, and every site states that it is separate
from the
max_message_countargument toreceive_messages. The word "cache"no longer appears in these docstrings.
received from the service and processed one at a time", which was misleading:
at the default a receive call requests
max_message_countmessages, not one.receive_messagesexplains how the two interact on each branch. Whenprefetch_countis 0 the receiver requestsmax_message_counton the call;when it is greater than 0 the call is served first from what the receiver
already holds and then continues on the standing prefetch credit.
max_message_countdocuments that passingNonefalls back toprefetch_count, so at the default it returns an empty list immediately. Themax_wait_timesentence is scoped so the two parameters no longer contradicteach other.
Applied to all 8
prefetch_countsites and bothreceive_messagesdocstrings,sync and async, with identical wording.
Verification
mainfor allfour files, so there is no API surface change and
api.mdis untouched.azure-pylint-guidelines-checker: 0 newfindings against
main. Proven non-vacuous by seeding a violation, which thegate reports.
well-formed paragraph, with a positive control confirming the check fires.
prefetch_count > 0path was measured: with an empty buffer the callcontinues receiving on standing credit, and when the buffer already satisfies
the request the wire is never touched.
Notes
Known gap, pre-existing and left unchanged: the RECEIVE_AND_DELETE warning is
scoped to
prefetch_count > 0, while at the default one standing credit means amessage can be buffered in that mode. It is unrelated to this issue and belongs
in its own change.