PYTHON-4021 Fix previous topologyDescription published when closing a client (#1769)

This commit is contained in:
Shane Harvey 2024-08-02 16:31:59 -07:00 committed by GitHub
parent 3d936d5c7d
commit d28ceb2058
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View File

@ -645,6 +645,7 @@ class Topology:
:exc:`~.errors.InvalidOperation`.
"""
async with self._lock:
old_td = self._description
for server in self._servers.values():
await server.close()
@ -664,7 +665,6 @@ class Topology:
# Publish only after releasing the lock.
if self._publish_tp:
assert self._events is not None
old_td = self._description
self._description = TopologyDescription(
TOPOLOGY_TYPE.Unknown,
{},

View File

@ -643,6 +643,7 @@ class Topology:
:exc:`~.errors.InvalidOperation`.
"""
with self._lock:
old_td = self._description
for server in self._servers.values():
server.close()
@ -662,7 +663,6 @@ class Topology:
# Publish only after releasing the lock.
if self._publish_tp:
assert self._events is not None
old_td = self._description
self._description = TopologyDescription(
TOPOLOGY_TYPE.Unknown,
{},