Skip to content

Commit 5a70039

Browse files
authored
PYTHON-4701 - Topology logging should use suppress_event (mongodb#1826)
1 parent ba8a139 commit 5a70039

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

pymongo/asynchronous/topology.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ async def _process_change(
475475
if server:
476476
await server.pool.ready()
477477

478-
suppress_event = (self._publish_server or self._publish_tp) and sd_old == server_description
478+
suppress_event = sd_old == server_description
479479
if self._publish_server and not suppress_event:
480480
assert self._events is not None
481481
self._events.put(
@@ -497,7 +497,7 @@ async def _process_change(
497497
(td_old, self._description, self._topology_id),
498498
)
499499
)
500-
if _SDAM_LOGGER.isEnabledFor(logging.DEBUG):
500+
if _SDAM_LOGGER.isEnabledFor(logging.DEBUG) and not suppress_event:
501501
_debug_log(
502502
_SDAM_LOGGER,
503503
topologyId=self._topology_id,

pymongo/synchronous/topology.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ def _process_change(
475475
if server:
476476
server.pool.ready()
477477

478-
suppress_event = (self._publish_server or self._publish_tp) and sd_old == server_description
478+
suppress_event = sd_old == server_description
479479
if self._publish_server and not suppress_event:
480480
assert self._events is not None
481481
self._events.put(
@@ -497,7 +497,7 @@ def _process_change(
497497
(td_old, self._description, self._topology_id),
498498
)
499499
)
500-
if _SDAM_LOGGER.isEnabledFor(logging.DEBUG):
500+
if _SDAM_LOGGER.isEnabledFor(logging.DEBUG) and not suppress_event:
501501
_debug_log(
502502
_SDAM_LOGGER,
503503
topologyId=self._topology_id,

test/unified_format.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1954,7 +1954,11 @@ def format_logs(log_list):
19541954

19551955
if client.get("ignoreExtraMessages", False):
19561956
actual_logs = actual_logs[: len(client["messages"])]
1957-
self.assertEqual(len(client["messages"]), len(actual_logs))
1957+
self.assertEqual(
1958+
len(client["messages"]),
1959+
len(actual_logs),
1960+
f"expected {client['messages']} but got {actual_logs}",
1961+
)
19581962
for expected_msg, actual_msg in zip(client["messages"], actual_logs):
19591963
expected_data, actual_data = expected_msg.pop("data"), actual_msg.pop("data")
19601964

0 commit comments

Comments
 (0)