Skip to content

PYTHON-4701 - Topology logging should use suppress_event #1826

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
merged 2 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pymongo/asynchronous/topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ async def _process_change(
if server:
await server.pool.ready()

suppress_event = (self._publish_server or self._publish_tp) and sd_old == server_description
suppress_event = sd_old == server_description
if self._publish_server and not suppress_event:
assert self._events is not None
self._events.put(
Expand All @@ -497,7 +497,7 @@ async def _process_change(
(td_old, self._description, self._topology_id),
)
)
if _SDAM_LOGGER.isEnabledFor(logging.DEBUG):
if _SDAM_LOGGER.isEnabledFor(logging.DEBUG) and not suppress_event:
_debug_log(
_SDAM_LOGGER,
topologyId=self._topology_id,
Expand Down
4 changes: 2 additions & 2 deletions pymongo/synchronous/topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ def _process_change(
if server:
server.pool.ready()

suppress_event = (self._publish_server or self._publish_tp) and sd_old == server_description
suppress_event = sd_old == server_description
if self._publish_server and not suppress_event:
assert self._events is not None
self._events.put(
Expand All @@ -497,7 +497,7 @@ def _process_change(
(td_old, self._description, self._topology_id),
)
)
if _SDAM_LOGGER.isEnabledFor(logging.DEBUG):
if _SDAM_LOGGER.isEnabledFor(logging.DEBUG) and not suppress_event:
_debug_log(
_SDAM_LOGGER,
topologyId=self._topology_id,
Expand Down
6 changes: 5 additions & 1 deletion test/unified_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -1954,7 +1954,11 @@ def format_logs(log_list):

if client.get("ignoreExtraMessages", False):
actual_logs = actual_logs[: len(client["messages"])]
self.assertEqual(len(client["messages"]), len(actual_logs))
self.assertEqual(
len(client["messages"]),
len(actual_logs),
f"expected {client['messages']} but got {actual_logs}",
)
for expected_msg, actual_msg in zip(client["messages"], actual_logs):
expected_data, actual_data = expected_msg.pop("data"), actual_msg.pop("data")

Expand Down
Loading