Skip to content

Commit d28ceb2

Browse files
authored
PYTHON-4021 Fix previous topologyDescription published when closing a client (mongodb#1769)
1 parent 3d936d5 commit d28ceb2

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

pymongo/asynchronous/topology.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,7 @@ async def close(self) -> None:
645645
:exc:`~.errors.InvalidOperation`.
646646
"""
647647
async with self._lock:
648+
old_td = self._description
648649
for server in self._servers.values():
649650
await server.close()
650651

@@ -664,7 +665,6 @@ async def close(self) -> None:
664665
# Publish only after releasing the lock.
665666
if self._publish_tp:
666667
assert self._events is not None
667-
old_td = self._description
668668
self._description = TopologyDescription(
669669
TOPOLOGY_TYPE.Unknown,
670670
{},

pymongo/synchronous/topology.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,7 @@ def close(self) -> None:
643643
:exc:`~.errors.InvalidOperation`.
644644
"""
645645
with self._lock:
646+
old_td = self._description
646647
for server in self._servers.values():
647648
server.close()
648649

@@ -662,7 +663,6 @@ def close(self) -> None:
662663
# Publish only after releasing the lock.
663664
if self._publish_tp:
664665
assert self._events is not None
665-
old_td = self._description
666666
self._description = TopologyDescription(
667667
TOPOLOGY_TYPE.Unknown,
668668
{},

0 commit comments

Comments
 (0)