MCPcopy Create free account
hub / github.com/apache/cassandra-python-driver / _wait_for_conn

Method _wait_for_conn

cassandra/pool.py:749–772  ·  view source on GitHub ↗
(self, timeout)

Source from the content-addressed store, hash-verified

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:

Callers 1

borrow_connectionMethod · 0.95

Calls 5

_await_available_connMethod · 0.95
ConnectionExceptionClass · 0.90
get_request_idMethod · 0.80
timeMethod · 0.45

Tested by

no test coverage detected