(self, conn: CT)
| 154 | pass |
| 155 | |
| 156 | def _add_to_pool(self, conn: CT) -> None: |
| 157 | # Remove the pool reference from the connection before returning it |
| 158 | # to the state, to avoid to create a reference loop. |
| 159 | # Also disable the warning for open connection in conn.__del__ |
| 160 | conn._pool = None |
| 161 | |
| 162 | # Critical section: if there is a client waiting give it the connection |
| 163 | # otherwise put it back into the pool. |
| 164 | with self._lock: |
| 165 | while self._waiting: |
| 166 | # If there is a client waiting (which is still waiting and |
| 167 | # hasn't timed out), give it the connection and notify it. |
| 168 | if self._waiting.popleft().set(conn): |
| 169 | break |
| 170 | else: |
| 171 | # No client waiting for a connection: close the connection |
| 172 | self._close_connection(conn) |
| 173 | # If we have been asked to wait for pool init, notify the |
| 174 | # waiter if the pool is ready. |
| 175 | if self._pool_full_event: |
| 176 | self._pool_full_event.set() |
| 177 | else: |
| 178 | # The connection created by wait shouldn't decrease the |
| 179 | # count of the number of connection used. |
| 180 | self._nconns -= 1 |
nothing calls this directly
no test coverage detected