Return copies from _get_free/in_use_connections and fix async _mock#3967
Merged
petyaslavova merged 2 commits intoredis:masterfrom Feb 20, 2026
Merged
Conversation
petyaslavova
approved these changes
Feb 20, 2026
Collaborator
petyaslavova
left a comment
There was a problem hiding this comment.
Hi @bysiber, thank you for your contribution! Great catch :)
Change looks good to me.
petyaslavova
added a commit
that referenced
this pull request
Feb 25, 2026
…3967) Co-authored-by: petyaslavova <petya.slavova@redis.com>
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.
Two issues in
MaintNotificationsConnectionPoolMixin:1.
_get_free_connectionsand_get_in_use_connectionsreturn direct references to internal collectionsThe lock is held only during
return, but callers iterate the returned collection outside the lock (e.g., inre_auth_callback). Another thread mutating the pool can causeRuntimeError: list/set changed size during iteration. TheBlockingConnectionPoolalready does this correctly by returning copies.Fixed by returning
list(self._available_connections)andset(self._in_use_connections).2. Sync
_mockisasync defbut called from sync contextre_auth_callbackis a sync method that passes_mockas a failure callback to the syncRetry.call_with_retry. Calling anasync deffrom sync context returns an unawaited coroutine. Removed theasynckeyword since this is intentionally a no-op callback.