-
Notifications
You must be signed in to change notification settings - Fork 431
fix(pylibmc): support client initialization using servers [backport 3.2] #12785
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains 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
Currently calling `Client(servers=[url])` throws an error as seen with the new test: [Example CI error](https://gitlab.ddbuild.io/DataDog/apm-reliability/dd-trace-py/-/jobs/847335230) ``` FAILED tests/contrib/pylibmc/test.py::TestPylibmcPatch::test_client_with_servers_option - TypeError: __init__() got multiple values for argument 'servers' FAILED tests/contrib/pylibmc/test.py::TestPylibmcPatch::test_client_with_servers_option - TypeError: __init__() got multiple values for argument 'servers' FAILED tests/contrib/pylibmc/test.py::TestPylibmcPatch::test_client_with_servers_option - TypeError: __init__() got multiple values for argument 'servers' ``` This is a bug in our integration logic because you can declare Clients with and without the `servers` portion: https://sendapatch.se/projects/pylibmc/reference.html . **Why did this bug occur?** When you call `pylibmc.Client(servers=[url])`, by the time it hits our patch code, `**kwargs` already stores `servers`. Then when this gets passed into the Client init, it sees two "servers" https://github.com/lericson/pylibmc/blob/1183e48eb86adf0c23c5164bfe2c2a4058234640/src/pylibmc/client.py#L126, hence the complaint about the multiple server arguments. A quick fix is to check if the kwargs contains servers and set up the client without duplicating it. Fixes APMS-15146 ## Checklist - [x] PR author has checked that all the criteria below are met - The PR description includes an overview of the change - The PR description articulates the motivation for the change - The change includes tests OR the PR description describes a testing strategy - The PR description notes risks associated with the change, if any - Newly-added code is easy to change - The change follows the [library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) - The change includes or references documentation updates if necessary - Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) ## Reviewer Checklist - [x] Reviewer has checked that all the criteria below are met - Title is accurate - All changes are related to the pull request's stated goal - Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes - Testing strategy adequately addresses listed risks - Newly-added code is easy to change - Release note makes sense to a user of the library - If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment - Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting) --------- Co-authored-by: Brett Langdon <[email protected]> Co-authored-by: Emmett Butler <[email protected]> (cherry picked from commit e08d99c)
wantsui
approved these changes
Mar 18, 2025
|
quinna-h
approved these changes
Mar 18, 2025
emmettbutler
approved these changes
Mar 19, 2025
7 tasks
mabdinur
approved these changes
Mar 25, 2025
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.
Backport e08d99c from #12721 to 3.2.
Currently calling
Client(servers=[url])
throws an error as seen with the new test:Example CI error
This is a bug in our integration logic because you can declare Clients with and without the
servers
portion: https://sendapatch.se/projects/pylibmc/reference.html .Why did this bug occur?
When you call
pylibmc.Client(servers=[url])
, by the time it hits our patch code,**kwargs
already storesservers
. Then when this gets passed into the Client init, it sees two "servers" https://github.com/lericson/pylibmc/blob/1183e48eb86adf0c23c5164bfe2c2a4058234640/src/pylibmc/client.py#L126, hence the complaint about the multiple server arguments.A quick fix is to check if the kwargs contains servers and set up the client without duplicating it.
Fixes APMS-15146
Checklist
Reviewer Checklist