Skip to content

Commit cb1f583

Browse files
committed
clean up logic
1 parent 301dc6f commit cb1f583

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

pymongo/asynchronous/topology.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -868,8 +868,6 @@ async def _handle_error(self, address: _Address, err_ctx: _ErrorContext) -> None
868868
# as Unknown and request an immediate check of the server.
869869
# Otherwise, we clear the connection pool, mark the server as
870870
# Unknown and request an immediate check of the server.
871-
if error.has_error_label("SystemOverloadedError"):
872-
return
873871
if hasattr(error, "code"):
874872
err_code = error.code
875873
else:
@@ -887,6 +885,9 @@ async def _handle_error(self, address: _Address, err_ctx: _ErrorContext) -> None
887885
server.request_check()
888886
elif not err_ctx.completed_handshake:
889887
# 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
890891
if not self._settings.load_balanced:
891892
await self._process_change(ServerDescription(address, error=error))
892893
# Clear the pool.

pymongo/synchronous/topology.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -866,8 +866,6 @@ def _handle_error(self, address: _Address, err_ctx: _ErrorContext) -> None:
866866
# as Unknown and request an immediate check of the server.
867867
# Otherwise, we clear the connection pool, mark the server as
868868
# Unknown and request an immediate check of the server.
869-
if error.has_error_label("SystemOverloadedError"):
870-
return
871869
if hasattr(error, "code"):
872870
err_code = error.code
873871
else:
@@ -885,6 +883,9 @@ def _handle_error(self, address: _Address, err_ctx: _ErrorContext) -> None:
885883
server.request_check()
886884
elif not err_ctx.completed_handshake:
887885
# 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
888889
if not self._settings.load_balanced:
889890
self._process_change(ServerDescription(address, error=error))
890891
# Clear the pool.

0 commit comments

Comments
 (0)