Skip to content

Pool

plateforme.core.database.pool

This module provides utilities for managing database pooling within the Plateforme framework using SQLAlchemy features.

NullPool

NullPool(
    creator: Union[_CreatorFnType, _CreatorWRecFnType],
    recycle: int = -1,
    echo: _EchoFlagType = None,
    logging_name: Optional[str] = None,
    reset_on_return: _ResetStyleArgType = True,
    events: Optional[
        List[Tuple[_ListenerFnType, str]]
    ] = None,
    dialect: Optional[Union[_ConnDialect, Dialect]] = None,
    pre_ping: bool = False,
    _dispatch: Optional[_DispatchCommon[Pool]] = None,
)

Bases: Pool

A Pool which does not pool connections.

Instead it literally opens and closes the underlying DB-API connection per each connection open/close.

Reconnect-related functions such as recycle and connection invalidation are not supported by this Pool implementation, since no connections are held persistently.

Construct a Pool.

:param creator: a callable function that returns a DB-API connection object. The function will be called with parameters.

:param recycle: If set to a value other than -1, number of seconds between connection recycling, which means upon checkout, if this timeout is surpassed the connection will be closed and replaced with a newly opened connection. Defaults to -1.

:param logging_name: String identifier which will be used within the "name" field of logging records generated within the "sqlalchemy.pool" logger. Defaults to a hexstring of the object's id.

:param echo: if True, the connection pool will log informational output such as when connections are invalidated as well as when connections are recycled to the default log handler, which defaults to sys.stdout for output.. If set to the string "debug", the logging will include pool checkouts and checkins.

The :paramref:_pool.Pool.echo parameter can also be set from the :func:_sa.create_engine call by using the :paramref:_sa.create_engine.echo_pool parameter.

.. seealso::

 :ref:`dbengine_logging` - further detail on how to configure
 logging.

:param reset_on_return: Determine steps to take on connections as they are returned to the pool, which were not otherwise handled by a :class:_engine.Connection. Available from :func:_sa.create_engine via the :paramref:_sa.create_engine.pool_reset_on_return parameter.

:paramref:_pool.Pool.reset_on_return can have any of these values:

  • "rollback" - call rollback() on the connection, to release locks and transaction resources. This is the default value. The vast majority of use cases should leave this value set.
  • "commit" - call commit() on the connection, to release locks and transaction resources. A commit here may be desirable for databases that cache query plans if a commit is emitted, such as Microsoft SQL Server. However, this value is more dangerous than 'rollback' because any data changes present on the transaction are committed unconditionally.
  • None - don't do anything on the connection. This setting may be appropriate if the database / DBAPI works in pure "autocommit" mode at all times, or if a custom reset handler is established using the :meth:.PoolEvents.reset event handler.

  • True - same as 'rollback', this is here for backwards compatibility.

  • False - same as None, this is here for backwards compatibility.

For further customization of reset on return, the :meth:.PoolEvents.reset event hook may be used which can perform any connection activity desired on reset.

.. seealso::

:ref:`pool_reset_on_return`

:meth:`.PoolEvents.reset`

:param events: a list of 2-tuples, each of the form (callable, target) which will be passed to :func:.event.listen upon construction. Provided here so that event listeners can be assigned via :func:_sa.create_engine before dialect-level listeners are applied.

:param dialect: a :class:.Dialect that will handle the job of calling rollback(), close(), or commit() on DBAPI connections. If omitted, a built-in "stub" dialect is used. Applications that make use of :func:_sa.create_engine should not use this parameter as it is handled by the engine creation strategy.

:param pre_ping: if True, the pool will emit a "ping" (typically "SELECT 1", but is dialect-specific) on the connection upon checkout, to test if the connection is alive or not. If not, the connection is transparently re-connected and upon success, all other pooled connections established prior to that timestamp are invalidated. Requires that a dialect is passed as well to interpret the disconnection error.

.. versionadded:: 1.2

Source code in .venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py
def __init__(
    self,
    creator: Union[_CreatorFnType, _CreatorWRecFnType],
    recycle: int = -1,
    echo: log._EchoFlagType = None,
    logging_name: Optional[str] = None,
    reset_on_return: _ResetStyleArgType = True,
    events: Optional[List[Tuple[_ListenerFnType, str]]] = None,
    dialect: Optional[Union[_ConnDialect, Dialect]] = None,
    pre_ping: bool = False,
    _dispatch: Optional[_DispatchCommon[Pool]] = None,
):
    """
    Construct a Pool.

    :param creator: a callable function that returns a DB-API
      connection object.  The function will be called with
      parameters.

    :param recycle: If set to a value other than -1, number of
      seconds between connection recycling, which means upon
      checkout, if this timeout is surpassed the connection will be
      closed and replaced with a newly opened connection. Defaults to -1.

    :param logging_name:  String identifier which will be used within
      the "name" field of logging records generated within the
      "sqlalchemy.pool" logger. Defaults to a hexstring of the object's
      id.

    :param echo: if True, the connection pool will log
     informational output such as when connections are invalidated
     as well as when connections are recycled to the default log handler,
     which defaults to ``sys.stdout`` for output..   If set to the string
     ``"debug"``, the logging will include pool checkouts and checkins.

     The :paramref:`_pool.Pool.echo` parameter can also be set from the
     :func:`_sa.create_engine` call by using the
     :paramref:`_sa.create_engine.echo_pool` parameter.

     .. seealso::

         :ref:`dbengine_logging` - further detail on how to configure
         logging.

    :param reset_on_return: Determine steps to take on
     connections as they are returned to the pool, which were
     not otherwise handled by a :class:`_engine.Connection`.
     Available from :func:`_sa.create_engine` via the
     :paramref:`_sa.create_engine.pool_reset_on_return` parameter.

     :paramref:`_pool.Pool.reset_on_return` can have any of these values:

     * ``"rollback"`` - call rollback() on the connection,
       to release locks and transaction resources.
       This is the default value.  The vast majority
       of use cases should leave this value set.
     * ``"commit"`` - call commit() on the connection,
       to release locks and transaction resources.
       A commit here may be desirable for databases that
       cache query plans if a commit is emitted,
       such as Microsoft SQL Server.  However, this
       value is more dangerous than 'rollback' because
       any data changes present on the transaction
       are committed unconditionally.
     * ``None`` - don't do anything on the connection.
       This setting may be appropriate if the database / DBAPI
       works in pure "autocommit" mode at all times, or if
       a custom reset handler is established using the
       :meth:`.PoolEvents.reset` event handler.

     * ``True`` - same as 'rollback', this is here for
       backwards compatibility.
     * ``False`` - same as None, this is here for
       backwards compatibility.

     For further customization of reset on return, the
     :meth:`.PoolEvents.reset` event hook may be used which can perform
     any connection activity desired on reset.

     .. seealso::

        :ref:`pool_reset_on_return`

        :meth:`.PoolEvents.reset`

    :param events: a list of 2-tuples, each of the form
     ``(callable, target)`` which will be passed to :func:`.event.listen`
     upon construction.   Provided here so that event listeners
     can be assigned via :func:`_sa.create_engine` before dialect-level
     listeners are applied.

    :param dialect: a :class:`.Dialect` that will handle the job
     of calling rollback(), close(), or commit() on DBAPI connections.
     If omitted, a built-in "stub" dialect is used.   Applications that
     make use of :func:`_sa.create_engine` should not use this parameter
     as it is handled by the engine creation strategy.

    :param pre_ping: if True, the pool will emit a "ping" (typically
     "SELECT 1", but is dialect-specific) on the connection
     upon checkout, to test if the connection is alive or not.   If not,
     the connection is transparently re-connected and upon success, all
     other pooled connections established prior to that timestamp are
     invalidated.     Requires that a dialect is passed as well to
     interpret the disconnection error.

     .. versionadded:: 1.2

    """
    if logging_name:
        self.logging_name = self._orig_logging_name = logging_name
    else:
        self._orig_logging_name = None

    log.instance_logger(self, echoflag=echo)
    self._creator = creator
    self._recycle = recycle
    self._invalidate_time = 0
    self._pre_ping = pre_ping
    self._reset_on_return = util.parse_user_argument_for_enum(
        reset_on_return,
        {
            ResetStyle.reset_rollback: ["rollback", True],
            ResetStyle.reset_none: ["none", None, False],
            ResetStyle.reset_commit: ["commit"],
        },
        "reset_on_return",
    )

    self.echo = echo

    if _dispatch:
        self.dispatch._update(_dispatch, only_propagate=False)
    if dialect:
        self._dialect = dialect
    if events:
        for fn, target in events:
            event.listen(self, target, fn)

connect

connect() -> PoolProxiedConnection

Return a DBAPI connection from the pool.

The connection is instrumented such that when its close() method is called, the connection will be returned to the pool.

Source code in .venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py
def connect(self) -> PoolProxiedConnection:
    """Return a DBAPI connection from the pool.

    The connection is instrumented such that when its
    ``close()`` method is called, the connection will be returned to
    the pool.

    """
    return _ConnectionFairy._checkout(self)

QueuePool

QueuePool(
    creator: Union[_CreatorFnType, _CreatorWRecFnType],
    pool_size: int = 5,
    max_overflow: int = 10,
    timeout: float = 30.0,
    use_lifo: bool = False,
    **kw: Any,
)

Bases: Pool

A :class:_pool.Pool that imposes a limit on the number of open connections.

:class:.QueuePool is the default pooling implementation used for all :class:_engine.Engine objects, unless the SQLite dialect is in use with a :memory: database.

Construct a QueuePool.

:param creator: a callable function that returns a DB-API connection object, same as that of :paramref:_pool.Pool.creator.

:param pool_size: The size of the pool to be maintained, defaults to 5. This is the largest number of connections that will be kept persistently in the pool. Note that the pool begins with no connections; once this number of connections is requested, that number of connections will remain. pool_size can be set to 0 to indicate no size limit; to disable pooling, use a :class:~sqlalchemy.pool.NullPool instead.

:param max_overflow: The maximum overflow size of the pool. When the number of checked-out connections reaches the size set in pool_size, additional connections will be returned up to this limit. When those additional connections are returned to the pool, they are disconnected and discarded. It follows then that the total number of simultaneous connections the pool will allow is pool_size + max_overflow, and the total number of "sleeping" connections the pool will allow is pool_size. max_overflow can be set to -1 to indicate no overflow limit; no limit will be placed on the total number of concurrent connections. Defaults to 10.

:param timeout: The number of seconds to wait before giving up on returning a connection. Defaults to 30.0. This can be a float but is subject to the limitations of Python time functions which may not be reliable in the tens of milliseconds.

:param use_lifo: use LIFO (last-in-first-out) when retrieving connections instead of FIFO (first-in-first-out). Using LIFO, a server-side timeout scheme can reduce the number of connections used during non-peak periods of use. When planning for server-side timeouts, ensure that a recycle or pre-ping strategy is in use to gracefully handle stale connections.

.. versionadded:: 1.3

.. seealso::

:ref:`pool_use_lifo`

:ref:`pool_disconnects`

:param **kw: Other keyword arguments including :paramref:_pool.Pool.recycle, :paramref:_pool.Pool.echo, :paramref:_pool.Pool.reset_on_return and others are passed to the :class:_pool.Pool constructor.

Source code in .venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py
def __init__(
    self,
    creator: Union[_CreatorFnType, _CreatorWRecFnType],
    pool_size: int = 5,
    max_overflow: int = 10,
    timeout: float = 30.0,
    use_lifo: bool = False,
    **kw: Any,
):
    r"""
    Construct a QueuePool.

    :param creator: a callable function that returns a DB-API
      connection object, same as that of :paramref:`_pool.Pool.creator`.

    :param pool_size: The size of the pool to be maintained,
      defaults to 5. This is the largest number of connections that
      will be kept persistently in the pool. Note that the pool
      begins with no connections; once this number of connections
      is requested, that number of connections will remain.
      ``pool_size`` can be set to 0 to indicate no size limit; to
      disable pooling, use a :class:`~sqlalchemy.pool.NullPool`
      instead.

    :param max_overflow: The maximum overflow size of the
      pool. When the number of checked-out connections reaches the
      size set in pool_size, additional connections will be
      returned up to this limit. When those additional connections
      are returned to the pool, they are disconnected and
      discarded. It follows then that the total number of
      simultaneous connections the pool will allow is pool_size +
      `max_overflow`, and the total number of "sleeping"
      connections the pool will allow is pool_size. `max_overflow`
      can be set to -1 to indicate no overflow limit; no limit
      will be placed on the total number of concurrent
      connections. Defaults to 10.

    :param timeout: The number of seconds to wait before giving up
      on returning a connection. Defaults to 30.0. This can be a float
      but is subject to the limitations of Python time functions which
      may not be reliable in the tens of milliseconds.

    :param use_lifo: use LIFO (last-in-first-out) when retrieving
      connections instead of FIFO (first-in-first-out). Using LIFO, a
      server-side timeout scheme can reduce the number of connections used
      during non-peak periods of use.   When planning for server-side
      timeouts, ensure that a recycle or pre-ping strategy is in use to
      gracefully handle stale connections.

      .. versionadded:: 1.3

      .. seealso::

        :ref:`pool_use_lifo`

        :ref:`pool_disconnects`

    :param \**kw: Other keyword arguments including
      :paramref:`_pool.Pool.recycle`, :paramref:`_pool.Pool.echo`,
      :paramref:`_pool.Pool.reset_on_return` and others are passed to the
      :class:`_pool.Pool` constructor.

    """
    Pool.__init__(self, creator, **kw)
    self._pool = self._queue_class(pool_size, use_lifo=use_lifo)
    self._overflow = 0 - pool_size
    self._max_overflow = -1 if pool_size == 0 else max_overflow
    self._timeout = timeout
    self._overflow_lock = threading.Lock()

connect

connect() -> PoolProxiedConnection

Return a DBAPI connection from the pool.

The connection is instrumented such that when its close() method is called, the connection will be returned to the pool.

Source code in .venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py
def connect(self) -> PoolProxiedConnection:
    """Return a DBAPI connection from the pool.

    The connection is instrumented such that when its
    ``close()`` method is called, the connection will be returned to
    the pool.

    """
    return _ConnectionFairy._checkout(self)

SingletonThreadPool

SingletonThreadPool(
    creator: Union[_CreatorFnType, _CreatorWRecFnType],
    pool_size: int = 5,
    **kw: Any,
)

Bases: Pool

A Pool that maintains one connection per thread.

Maintains one connection per each thread, never moving a connection to a thread other than the one which it was created in.

.. warning:: the :class:.SingletonThreadPool will call .close() on arbitrary connections that exist beyond the size setting of pool_size, e.g. if more unique thread identities than what pool_size states are used. This cleanup is non-deterministic and not sensitive to whether or not the connections linked to those thread identities are currently in use.

:class:.SingletonThreadPool may be improved in a future release, however in its current status it is generally used only for test scenarios using a SQLite :memory: database and is not recommended for production use.

Options are the same as those of :class:_pool.Pool, as well as:

:param pool_size: The number of threads in which to maintain connections at once. Defaults to five.

:class:.SingletonThreadPool is used by the SQLite dialect automatically when a memory-based database is used. See :ref:sqlite_toplevel.

Source code in .venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py
def __init__(
    self,
    creator: Union[_CreatorFnType, _CreatorWRecFnType],
    pool_size: int = 5,
    **kw: Any,
):
    Pool.__init__(self, creator, **kw)
    self._conn = threading.local()
    self._fairy = threading.local()
    self._all_conns: Set[ConnectionPoolEntry] = set()
    self.size = pool_size

dispose

dispose() -> None

Dispose of this pool.

Source code in .venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py
def dispose(self) -> None:
    """Dispose of this pool."""

    for conn in self._all_conns:
        try:
            conn.close()
        except Exception:
            # pysqlite won't even let you close a conn from a thread
            # that didn't create it
            pass

    self._all_conns.clear()

StaticPool

StaticPool(
    creator: Union[_CreatorFnType, _CreatorWRecFnType],
    recycle: int = -1,
    echo: _EchoFlagType = None,
    logging_name: Optional[str] = None,
    reset_on_return: _ResetStyleArgType = True,
    events: Optional[
        List[Tuple[_ListenerFnType, str]]
    ] = None,
    dialect: Optional[Union[_ConnDialect, Dialect]] = None,
    pre_ping: bool = False,
    _dispatch: Optional[_DispatchCommon[Pool]] = None,
)

Bases: Pool

A Pool of exactly one connection, used for all requests.

Reconnect-related functions such as recycle and connection invalidation (which is also used to support auto-reconnect) are only partially supported right now and may not yield good results.

Construct a Pool.

:param creator: a callable function that returns a DB-API connection object. The function will be called with parameters.

:param recycle: If set to a value other than -1, number of seconds between connection recycling, which means upon checkout, if this timeout is surpassed the connection will be closed and replaced with a newly opened connection. Defaults to -1.

:param logging_name: String identifier which will be used within the "name" field of logging records generated within the "sqlalchemy.pool" logger. Defaults to a hexstring of the object's id.

:param echo: if True, the connection pool will log informational output such as when connections are invalidated as well as when connections are recycled to the default log handler, which defaults to sys.stdout for output.. If set to the string "debug", the logging will include pool checkouts and checkins.

The :paramref:_pool.Pool.echo parameter can also be set from the :func:_sa.create_engine call by using the :paramref:_sa.create_engine.echo_pool parameter.

.. seealso::

 :ref:`dbengine_logging` - further detail on how to configure
 logging.

:param reset_on_return: Determine steps to take on connections as they are returned to the pool, which were not otherwise handled by a :class:_engine.Connection. Available from :func:_sa.create_engine via the :paramref:_sa.create_engine.pool_reset_on_return parameter.

:paramref:_pool.Pool.reset_on_return can have any of these values:

  • "rollback" - call rollback() on the connection, to release locks and transaction resources. This is the default value. The vast majority of use cases should leave this value set.
  • "commit" - call commit() on the connection, to release locks and transaction resources. A commit here may be desirable for databases that cache query plans if a commit is emitted, such as Microsoft SQL Server. However, this value is more dangerous than 'rollback' because any data changes present on the transaction are committed unconditionally.
  • None - don't do anything on the connection. This setting may be appropriate if the database / DBAPI works in pure "autocommit" mode at all times, or if a custom reset handler is established using the :meth:.PoolEvents.reset event handler.

  • True - same as 'rollback', this is here for backwards compatibility.

  • False - same as None, this is here for backwards compatibility.

For further customization of reset on return, the :meth:.PoolEvents.reset event hook may be used which can perform any connection activity desired on reset.

.. seealso::

:ref:`pool_reset_on_return`

:meth:`.PoolEvents.reset`

:param events: a list of 2-tuples, each of the form (callable, target) which will be passed to :func:.event.listen upon construction. Provided here so that event listeners can be assigned via :func:_sa.create_engine before dialect-level listeners are applied.

:param dialect: a :class:.Dialect that will handle the job of calling rollback(), close(), or commit() on DBAPI connections. If omitted, a built-in "stub" dialect is used. Applications that make use of :func:_sa.create_engine should not use this parameter as it is handled by the engine creation strategy.

:param pre_ping: if True, the pool will emit a "ping" (typically "SELECT 1", but is dialect-specific) on the connection upon checkout, to test if the connection is alive or not. If not, the connection is transparently re-connected and upon success, all other pooled connections established prior to that timestamp are invalidated. Requires that a dialect is passed as well to interpret the disconnection error.

.. versionadded:: 1.2

Source code in .venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py
def __init__(
    self,
    creator: Union[_CreatorFnType, _CreatorWRecFnType],
    recycle: int = -1,
    echo: log._EchoFlagType = None,
    logging_name: Optional[str] = None,
    reset_on_return: _ResetStyleArgType = True,
    events: Optional[List[Tuple[_ListenerFnType, str]]] = None,
    dialect: Optional[Union[_ConnDialect, Dialect]] = None,
    pre_ping: bool = False,
    _dispatch: Optional[_DispatchCommon[Pool]] = None,
):
    """
    Construct a Pool.

    :param creator: a callable function that returns a DB-API
      connection object.  The function will be called with
      parameters.

    :param recycle: If set to a value other than -1, number of
      seconds between connection recycling, which means upon
      checkout, if this timeout is surpassed the connection will be
      closed and replaced with a newly opened connection. Defaults to -1.

    :param logging_name:  String identifier which will be used within
      the "name" field of logging records generated within the
      "sqlalchemy.pool" logger. Defaults to a hexstring of the object's
      id.

    :param echo: if True, the connection pool will log
     informational output such as when connections are invalidated
     as well as when connections are recycled to the default log handler,
     which defaults to ``sys.stdout`` for output..   If set to the string
     ``"debug"``, the logging will include pool checkouts and checkins.

     The :paramref:`_pool.Pool.echo` parameter can also be set from the
     :func:`_sa.create_engine` call by using the
     :paramref:`_sa.create_engine.echo_pool` parameter.

     .. seealso::

         :ref:`dbengine_logging` - further detail on how to configure
         logging.

    :param reset_on_return: Determine steps to take on
     connections as they are returned to the pool, which were
     not otherwise handled by a :class:`_engine.Connection`.
     Available from :func:`_sa.create_engine` via the
     :paramref:`_sa.create_engine.pool_reset_on_return` parameter.

     :paramref:`_pool.Pool.reset_on_return` can have any of these values:

     * ``"rollback"`` - call rollback() on the connection,
       to release locks and transaction resources.
       This is the default value.  The vast majority
       of use cases should leave this value set.
     * ``"commit"`` - call commit() on the connection,
       to release locks and transaction resources.
       A commit here may be desirable for databases that
       cache query plans if a commit is emitted,
       such as Microsoft SQL Server.  However, this
       value is more dangerous than 'rollback' because
       any data changes present on the transaction
       are committed unconditionally.
     * ``None`` - don't do anything on the connection.
       This setting may be appropriate if the database / DBAPI
       works in pure "autocommit" mode at all times, or if
       a custom reset handler is established using the
       :meth:`.PoolEvents.reset` event handler.

     * ``True`` - same as 'rollback', this is here for
       backwards compatibility.
     * ``False`` - same as None, this is here for
       backwards compatibility.

     For further customization of reset on return, the
     :meth:`.PoolEvents.reset` event hook may be used which can perform
     any connection activity desired on reset.

     .. seealso::

        :ref:`pool_reset_on_return`

        :meth:`.PoolEvents.reset`

    :param events: a list of 2-tuples, each of the form
     ``(callable, target)`` which will be passed to :func:`.event.listen`
     upon construction.   Provided here so that event listeners
     can be assigned via :func:`_sa.create_engine` before dialect-level
     listeners are applied.

    :param dialect: a :class:`.Dialect` that will handle the job
     of calling rollback(), close(), or commit() on DBAPI connections.
     If omitted, a built-in "stub" dialect is used.   Applications that
     make use of :func:`_sa.create_engine` should not use this parameter
     as it is handled by the engine creation strategy.

    :param pre_ping: if True, the pool will emit a "ping" (typically
     "SELECT 1", but is dialect-specific) on the connection
     upon checkout, to test if the connection is alive or not.   If not,
     the connection is transparently re-connected and upon success, all
     other pooled connections established prior to that timestamp are
     invalidated.     Requires that a dialect is passed as well to
     interpret the disconnection error.

     .. versionadded:: 1.2

    """
    if logging_name:
        self.logging_name = self._orig_logging_name = logging_name
    else:
        self._orig_logging_name = None

    log.instance_logger(self, echoflag=echo)
    self._creator = creator
    self._recycle = recycle
    self._invalidate_time = 0
    self._pre_ping = pre_ping
    self._reset_on_return = util.parse_user_argument_for_enum(
        reset_on_return,
        {
            ResetStyle.reset_rollback: ["rollback", True],
            ResetStyle.reset_none: ["none", None, False],
            ResetStyle.reset_commit: ["commit"],
        },
        "reset_on_return",
    )

    self.echo = echo

    if _dispatch:
        self.dispatch._update(_dispatch, only_propagate=False)
    if dialect:
        self._dialect = dialect
    if events:
        for fn, target in events:
            event.listen(self, target, fn)

connect

connect() -> PoolProxiedConnection

Return a DBAPI connection from the pool.

The connection is instrumented such that when its close() method is called, the connection will be returned to the pool.

Source code in .venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py
def connect(self) -> PoolProxiedConnection:
    """Return a DBAPI connection from the pool.

    The connection is instrumented such that when its
    ``close()`` method is called, the connection will be returned to
    the pool.

    """
    return _ConnectionFairy._checkout(self)