MCPcopy Create free account
hub / github.com/MagicStack/asyncpg / _PoolConnectionHolderQueue

Class _PoolConnectionHolderQueue

asyncpg/pool.py:28–43  ·  view source on GitHub ↗

Prefer live connections, with LIFO ordering within each group.

Source from the content-addressed store, hash-verified

26
27
28class _PoolConnectionHolderQueue(asyncio.LifoQueue):
29 """Prefer live connections, with LIFO ordering within each group."""
30
31 def _get(self):
32 for i in range(len(self._queue) - 1, -1, -1):
33 if self._queue[i].is_connected():
34 return self._queue.pop(i)
35 return super()._get()
36
37 def get_disconnected_nowait(self):
38 for i in range(len(self._queue) - 1, -1, -1):
39 if not self._queue[i].is_connected():
40 holder = self._queue.pop(i)
41 self._wakeup_next(self._putters)
42 return holder
43 raise asyncio.QueueEmpty
44
45
46class PoolConnectionProxyMeta(type):

Callers 1

_initializeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected