(self, timeout)
| 747 | self._conn_available_condition.notify_all() |
| 748 | |
| 749 | def _wait_for_conn(self, timeout): |
| 750 | start = time.time() |
| 751 | remaining = timeout |
| 752 | |
| 753 | while remaining > 0: |
| 754 | # wait on our condition for the possibility that a connection |
| 755 | # is useable |
| 756 | self._await_available_conn(remaining) |
| 757 | |
| 758 | # self.shutdown() may trigger the above Condition |
| 759 | if self.is_shutdown: |
| 760 | raise ConnectionException("Pool is shutdown") |
| 761 | |
| 762 | conns = self._connections |
| 763 | if conns: |
| 764 | least_busy = min(conns, key=lambda c: c.in_flight) |
| 765 | with least_busy.lock: |
| 766 | if least_busy.in_flight < least_busy.max_request_id: |
| 767 | least_busy.in_flight += 1 |
| 768 | return least_busy, least_busy.get_request_id() |
| 769 | |
| 770 | remaining = timeout - (time.time() - start) |
| 771 | |
| 772 | raise NoConnectionsAvailable() |
| 773 | |
| 774 | def return_connection(self, connection, stream_was_orphaned=False): |
| 775 | with connection.lock: |
no test coverage detected