Skip to content

Commit 845f17a

Browse files
committed
only backoff if conn is closed
1 parent c974d36 commit 845f17a

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

pymongo/asynchronous/pool.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,11 +1102,11 @@ async def connect(self, handler: Optional[_MongoClientErrorHandler] = None) -> A
11021102

11031103
await conn.authenticate()
11041104
# Catch KeyboardInterrupt, CancelledError, etc. and cleanup.
1105-
except BaseException as e:
1105+
except BaseException:
11061106
async with self.lock:
11071107
self.active_contexts.discard(conn.cancel_context)
11081108
# Enter backoff mode and reconnect on establishment failure.
1109-
if type(e) == AutoReconnect:
1109+
if conn.conn_closed():
11101110
self._backoff += 1
11111111
# TODO: emit a message about backoff.
11121112
print("backing off", self._backoff) # noqa: T201

pymongo/synchronous/pool.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,11 +1098,11 @@ def connect(self, handler: Optional[_MongoClientErrorHandler] = None) -> Connect
10981098

10991099
conn.authenticate()
11001100
# Catch KeyboardInterrupt, CancelledError, etc. and cleanup.
1101-
except BaseException as e:
1101+
except BaseException:
11021102
with self.lock:
11031103
self.active_contexts.discard(conn.cancel_context)
11041104
# Enter backoff mode and reconnect on establishment failure.
1105-
if type(e) == AutoReconnect:
1105+
if conn.conn_closed():
11061106
self._backoff += 1
11071107
# TODO: emit a message about backoff.
11081108
print("backing off", self._backoff) # noqa: T201

0 commit comments

Comments
 (0)