@@ -1313,14 +1313,7 @@ async def _get_conn(
13131313 self ._raise_if_not_ready (checkout_started_time , emit_event = True )
13141314 while not (self .requests < self .max_pool_size ):
13151315 timeout = deadline - time .monotonic () if deadline else None
1316- if self ._backoff and (self ._backoff_connection_time > time .monotonic ()):
1317- timeout = 0.01
13181316 if not await _async_cond_wait (self .size_cond , timeout ):
1319- # Check whether we should continue to wait for the backoff condition.
1320- if self ._backoff and deadline is None or deadline < time .monotonic ():
1321- if self ._backoff_connection_time > time .monotonic ():
1322- continue
1323- break
13241317 # Timed out, notify the next thread to ensure a
13251318 # timeout doesn't consume the condition.
13261319 if self .requests < self .max_pool_size :
@@ -1339,12 +1332,19 @@ async def _get_conn(
13391332 incremented = True
13401333 while conn is None :
13411334 # CMAP: we MUST wait for either maxConnecting OR for a socket
1342- # to be checked back into the pool.
1335+ # to be checked back into the pool OR for the backoff period to expire .
13431336 async with self ._max_connecting_cond :
13441337 self ._raise_if_not_ready (checkout_started_time , emit_event = False )
13451338 while not (self .conns or self ._pending < self .max_connecting ):
13461339 timeout = deadline - time .monotonic () if deadline else None
1340+ if self ._backoff and (self ._backoff_connection_time > time .monotonic ()):
1341+ timeout = 0.01
13471342 if not await _async_cond_wait (self ._max_connecting_cond , timeout ):
1343+ # Check whether we should continue to wait for the backoff condition.
1344+ if self ._backoff and deadline is None or deadline < time .monotonic ():
1345+ if self ._backoff_connection_time > time .monotonic ():
1346+ continue
1347+ break
13481348 # Timed out, notify the next thread to ensure a
13491349 # timeout doesn't consume the condition.
13501350 if self .conns or self ._pending < self .max_connecting :
0 commit comments