File tree Expand file tree Collapse file tree 2 files changed +4
-12
lines changed Expand file tree Collapse file tree 2 files changed +4
-12
lines changed Original file line number Diff line number Diff line change 4949from pymongo .errors import ( # type:ignore[attr-defined]
5050 AutoReconnect ,
5151 ConfigurationError ,
52- ConnectionFailure ,
5352 DocumentTooLarge ,
5453 ExecutionTimeout ,
5554 InvalidOperation ,
56- NetworkTimeout ,
5755 NotPrimaryError ,
5856 OperationFailure ,
5957 PyMongoError ,
6058 WaitQueueTimeoutError ,
61- _OperationCancelled ,
6259)
6360from pymongo .hello import Hello , HelloCompat
6461from pymongo .helpers_shared import _get_timeout_details , format_timeout_details
@@ -1109,11 +1106,10 @@ async def connect(self, handler: Optional[_MongoClientErrorHandler] = None) -> A
11091106 async with self .lock :
11101107 self .active_contexts .discard (conn .cancel_context )
11111108 # Enter backoff mode and reconnect on establishment failure.
1112- if isinstance (e , ConnectionFailure ) and not isinstance (
1113- e , (_OperationCancelled , NetworkTimeout )
1114- ):
1109+ if type (e ) == AutoReconnect :
11151110 self ._backoff += 1
11161111 # TODO: emit a message about backoff.
1112+ print ("backing off" , self ._backoff ) # noqa: T201
11171113 return await self .connect (handler )
11181114 await conn .close_conn (ConnectionClosedReason .ERROR )
11191115 raise
Original file line number Diff line number Diff line change 4646from pymongo .errors import ( # type:ignore[attr-defined]
4747 AutoReconnect ,
4848 ConfigurationError ,
49- ConnectionFailure ,
5049 DocumentTooLarge ,
5150 ExecutionTimeout ,
5251 InvalidOperation ,
53- NetworkTimeout ,
5452 NotPrimaryError ,
5553 OperationFailure ,
5654 PyMongoError ,
5755 WaitQueueTimeoutError ,
58- _OperationCancelled ,
5956)
6057from pymongo .hello import Hello , HelloCompat
6158from pymongo .helpers_shared import _get_timeout_details , format_timeout_details
@@ -1105,11 +1102,10 @@ def connect(self, handler: Optional[_MongoClientErrorHandler] = None) -> Connect
11051102 with self .lock :
11061103 self .active_contexts .discard (conn .cancel_context )
11071104 # Enter backoff mode and reconnect on establishment failure.
1108- if isinstance (e , ConnectionFailure ) and not isinstance (
1109- e , (_OperationCancelled , NetworkTimeout )
1110- ):
1105+ if type (e ) == AutoReconnect :
11111106 self ._backoff += 1
11121107 # TODO: emit a message about backoff.
1108+ print ("backing off" , self ._backoff ) # noqa: T201
11131109 return self .connect (handler )
11141110 conn .close_conn (ConnectionClosedReason .ERROR )
11151111 raise
You can’t perform that action at this time.
0 commit comments