(self, deadline: float)
| 220 | ) from None |
| 221 | |
| 222 | def _getconn_with_check_loop(self, deadline: float) -> CT: |
| 223 | attempt: AttemptWithBackoff | None = None |
| 224 | |
| 225 | while True: |
| 226 | conn = self._getconn_unchecked(deadline - monotonic()) |
| 227 | try: |
| 228 | self._check_connection(conn) |
| 229 | except CLIENT_EXCEPTIONS: |
| 230 | self._putconn(conn, from_getconn=True) |
| 231 | else: |
| 232 | logger.info("connection given by %r", self.name) |
| 233 | return conn |
| 234 | |
| 235 | # Delay further checks to avoid a busy loop, using the same |
| 236 | # backoff policy used in reconnection attempts. |
| 237 | now = monotonic() |
| 238 | if not attempt: |
| 239 | attempt = AttemptWithBackoff(timeout=deadline - now) |
| 240 | else: |
| 241 | attempt.update_delay(now) |
| 242 | |
| 243 | if attempt.time_to_give_up(now): |
| 244 | raise PoolTimeout() |
| 245 | else: |
| 246 | sleep(attempt.delay) |
| 247 | |
| 248 | def _getconn_unchecked(self, timeout: float) -> CT: |
| 249 | # Critical section: decide here if there's a connection ready |
no test coverage detected