(self, timeout)
| 875 | return PoolAcquireContext(self, timeout) |
| 876 | |
| 877 | async def _acquire(self, timeout): |
| 878 | async def _acquire_impl(): |
| 879 | ch = await self._queue.get() # type: PoolConnectionHolder |
| 880 | try: |
| 881 | proxy = await ch.acquire() # type: PoolConnectionProxy |
| 882 | except (Exception, asyncio.CancelledError): |
| 883 | self._queue.put_nowait(ch) |
| 884 | raise |
| 885 | else: |
| 886 | # Record the timeout, as we will apply it by default |
| 887 | # in release(). |
| 888 | ch._timeout = timeout |
| 889 | return proxy |
| 890 | |
| 891 | if self._closing: |
| 892 | raise exceptions.InterfaceError('pool is closing') |
| 893 | self._check_init() |
| 894 | |
| 895 | if timeout is None: |
| 896 | return await _acquire_impl() |
| 897 | else: |
| 898 | return await compat.wait_for( |
| 899 | _acquire_impl(), timeout=timeout) |
| 900 | |
| 901 | async def release(self, connection, *, timeout=None): |
| 902 | """Release a database connection back to the pool. |
no test coverage detected