Skip to content

PYTHON-5344 and PYTHON-5403 Allow Instantiated MongoClients to Send Client Metadata On-Demand #2358

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

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

sleepyStick
Copy link
Contributor

@sleepyStick sleepyStick commented Jun 2, 2025

https://jira.mongodb.org/browse/PYTHON-5344
https://jira.mongodb.org/browse/PYTHON-5403 (ticket for async tests)

Notes:

  • I used mockupDB to capture the metadata that the client sends in the handshake
  • i put the tests in the normal tests folder (as opposed to the test/mockupdb) to utilize synchro for the async -> sync tests.

@@ -1040,6 +1041,20 @@ async def target() -> bool:
self._kill_cursors_executor = executor
self._opened = False

def _append_metadata(self, driver_info: DriverInfo) -> None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs to be public: "Specifies that drivers MUST provide an API to allow updating client metadata (name, version, platform) after initialization"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh good catch!

@sleepyStick sleepyStick marked this pull request as ready for review June 18, 2025 00:18
@sleepyStick sleepyStick changed the title PYTHON-5344 Allow Instantiated MongoClients to Send Client Metadata On-Demand PYTHON-5344 and PYTHON5403 Allow Instantiated MongoClients to Send Client Metadata On-Demand Jun 18, 2025
@sleepyStick sleepyStick changed the title PYTHON-5344 and PYTHON5403 Allow Instantiated MongoClients to Send Client Metadata On-Demand PYTHON-5344 and PYTHON-5403 Allow Instantiated MongoClients to Send Client Metadata On-Demand Jun 18, 2025
)

# Generate unified tests.
globals().update(generate_test_classes(_TEST_PATH, module=__name__, RUN_ON_SERVERLESS=True))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't test on serverless anymore, so you can remove RUN_ON_SERVERLESS.

@@ -703,6 +704,7 @@ async def _collectionOperation_createChangeStream(self, target, *args, **kwargs)
async def _databaseOperation_runCommand(self, target, **kwargs):
self.__raise_if_unsupported("runCommand", target, AsyncDatabase)
# Ensure the first key is the command name.
print(kwargs)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's several print statements left in this file

) -> None:
# send initial metadata
name, version, platform, metadata = await self.send_ping_and_get_metadata(client, True)
await asyncio.sleep(0.005)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this specific sleep? Is this a potential source of flakiness?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants