From: Daniele Varrazzo Date: Tue, 27 Jul 2021 19:51:36 +0000 (+0200) Subject: Docs pool cleanup X-Git-Tag: 3.0.dev2~28 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3419538ba51b301e97ee312ac7f3e1b936c5d06d;p=thirdparty%2Fpsycopg.git Docs pool cleanup --- diff --git a/docs/advanced/pool.rst b/docs/advanced/pool.rst index dcdf046a7..541a24cc3 100644 --- a/docs/advanced/pool.rst +++ b/docs/advanced/pool.rst @@ -109,7 +109,7 @@ to restart it. If more than *min_size* connections are requested concurrently, new ones are created, up to *max_size*. Note that the connections are always created by the background workers, not by the thread asking the connection: if a client -requires a new connection, and a previous client terminates its job before the +requests a new connection, and a previous client terminates its job before the new connection is ready, the waiting client will be served the existing connection. This is especially useful in scenarios where the time to connect is longer than the time the connection is used (see `this analysis`__, for diff --git a/docs/api/pool.rst b/docs/api/pool.rst index bf6451166..140899e9b 100644 --- a/docs/api/pool.rst +++ b/docs/api/pool.rst @@ -11,7 +11,7 @@ creates and maintains a limited amount of PostgreSQL connections and allows a larger number of users to use them. See :ref:`connection-pools` for more details and usage pattern. -There package implement two connection pools: `ConnectionPool` is a +This module implement two connection pools: `ConnectionPool` is a synchronous connection pool yielding `~psycopg.Connection` objects and can be used by multithread applications. `AsyncConnectionPool` has a similar interface, but with `asyncio` functions replacing blocking functions, and @@ -89,8 +89,8 @@ The `!ConnectionPool` class :type timeout: `!float`, default: 30 seconds :param max_waiting: Maximum number of requests that can be queued to the - pool. Requesting will fail, raising `TooManyRequests`. - 0 means no queue limit. + pool, after which new requests will fail, raising + `TooManyRequests`. 0 means no queue limit. :type max_waiting: `!int`, default: 0 :param max_lifetime: The maximum lifetime of a connection in the pool, in @@ -176,6 +176,8 @@ The `!ConnectionPool` class .. automethod:: getconn .. automethod:: putconn +Pool exceptions +--------------- .. autoclass:: PoolTimeout() @@ -195,8 +197,8 @@ The `!AsyncConnectionPool` class `!AsyncConnectionPool` has a very similar interface to the `ConnectionPool` class but its blocking method are implemented as `async` coroutines. It -returns `AsyncConnection` instances, or its subclasses if specified so in the -*connection_class* parameter. +returns `~psycopg.AsyncConnection` instances, or its subclasses if specified +so in the *connection_class* parameter. Only the function with different signature from `!ConnectionPool` are listed here. diff --git a/psycopg/psycopg/pool/pool.py b/psycopg/psycopg/pool/pool.py index 2de6918ea..7ba7d3d01 100644 --- a/psycopg/psycopg/pool/pool.py +++ b/psycopg/psycopg/pool/pool.py @@ -132,7 +132,7 @@ class ConnectionPool(BasePool[Connection[Any]]): ) -> Iterator[Connection[Any]]: """Context manager to obtain a connection from the pool. - Returned the connection immediately if available, otherwise wait up to + Return the connection immediately if available, otherwise wait up to *timeout* or `self.timeout` seconds and throw `PoolTimeout` if a connection is not available in time. @@ -261,9 +261,9 @@ class ConnectionPool(BasePool[Connection[Any]]): with a `PoolClosed` exception. Currently used connections will not be closed until returned to the pool. - Wait *timeout* for threads to terminate their job, if positive. If - timeout expires the pool is closed anyway, although it may raise some - warnings on exit. + Wait *timeout* seconds for threads to terminate their job, if positive. + If the timeout expires the pool is closed anyway, although it may raise + some warnings on exit. """ if self._closed: return