Skip to content

Commit d1bb15c

Browse files
committed
clean up logic
1 parent cb1f583 commit d1bb15c

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

pymongo/asynchronous/topology.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -885,13 +885,11 @@ async def _handle_error(self, address: _Address, err_ctx: _ErrorContext) -> None
885885
server.request_check()
886886
elif not err_ctx.completed_handshake:
887887
# Unknown command error during the connection handshake.
888-
# Ignore if it has the backpressure error label applied.
889-
if error.has_error_label("SystemOverloadedError"):
890-
return
891888
if not self._settings.load_balanced:
892889
await self._process_change(ServerDescription(address, error=error))
893-
# Clear the pool.
894-
await server.reset(service_id)
890+
# Clear the pool if the backpressure label was not applied.
891+
if not error.has_error_label("SystemOverloadedError"):
892+
await server.reset(service_id)
895893
elif isinstance(error, ConnectionFailure):
896894
if isinstance(error, WaitQueueTimeoutError) or (
897895
error.has_error_label("SystemOverloadedError")

pymongo/synchronous/topology.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -883,13 +883,11 @@ def _handle_error(self, address: _Address, err_ctx: _ErrorContext) -> None:
883883
server.request_check()
884884
elif not err_ctx.completed_handshake:
885885
# Unknown command error during the connection handshake.
886-
# Ignore if it has the backpressure error label applied.
887-
if error.has_error_label("SystemOverloadedError"):
888-
return
889886
if not self._settings.load_balanced:
890887
self._process_change(ServerDescription(address, error=error))
891-
# Clear the pool.
892-
server.reset(service_id)
888+
# Clear the pool if the backpressure label was not applied.
889+
if not error.has_error_label("SystemOverloadedError"):
890+
server.reset(service_id)
893891
elif isinstance(error, ConnectionFailure):
894892
if isinstance(error, WaitQueueTimeoutError) or (
895893
error.has_error_label("SystemOverloadedError")

0 commit comments

Comments
 (0)