'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 non -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, connections being pulled and retrieved
from the pool will be logged to the standard output, as well
as pool sizing information.  Echoing can also be achieved by
enabling logging for the "sqlalchemy.pool"
namespace. Defaults to False.
:param use_threadlocal: If set to True, repeated calls to
:meth:`connect` within the same application thread will be
guaranteed to return the same connection object, if one has
already been retrieved from the pool and has not been
returned yet.  Offers a slight performance advantage at the
cost of individual transactions by default.  The
:meth:`.Pool.unique_connection` method is provided to return
a consistenty unique connection to bypass this behavior
when the flag is set.
.. warning::  The :paramref:`.Pool.use_threadlocal` flag
**does not affect the behavior** of :meth:`.Engine.connect`.
:meth:`.Engine.connect` makes use of the :meth:`.Pool.unique_connection`
method which **does not use thread local context**.
To produce a :class:`.Connection` which refers to the
:meth:`.Pool.connect` method, use
:meth:`.Engine.contextual_connect`.
Note that other SQLAlchemy connectivity systems such as
:meth:`.Engine.execute` as well as the orm
:class:`.Session` make use of
:meth:`.Engine.contextual_connect` internally, so these functions
are compatible with the :paramref:`.Pool.use_threadlocal` setting.
.. seealso::
:ref:`threadlocal_strategy` - contains detail on the
"threadlocal" engine strategy, which provides a more comprehensive
approach to "threadlocal" connectivity for the specific
use case of using :class:`.Engine` and :class:`.Connection` objects
directly.
:param reset_on_return: Determine steps to take on
connections as they are returned to the 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.
* ``True`` - same as \'rollback\', this is here for
backwards compatibility.
* ``"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 should only be made on a database
that has no transaction support at all,
namely MySQL MyISAM.   By not doing anything,
performance can be improved.   This
setting should **never be selected** for a
database that supports transactions,
as it will lead to deadlocks and stale
state.
* ``False`` - same as None, this is here for
backwards compatibility.
.. versionchanged:: 0.7.6
:paramref:`.Pool.reset_on_return` accepts ``"rollback"``
and ``"commit"`` arguments.
: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:`.create_engine` before dialect-level
listeners are applied.
:param listeners: Deprecated.  A list of
:class:`~sqlalchemy.interfaces.PoolListener`-like objects or
dictionaries of callables that receive events when DB-API
connections are created, checked out and checked in to the
pool.  This has been superseded by
:func:`~sqlalchemy.event.listen`.'

def __init__(self, creator, recycle=(-1), echo=None, use_threadlocal=False, logging_name=None, reset_on_return=True, listeners=None, events=None, _dispatch=None, _dialect=None):

    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._threadconns = threading.local()
    self._creator = creator
    self._recycle = recycle
    self._invalidate_time = 0
    self._use_threadlocal = use_threadlocal
    if (reset_on_return in ('rollback', True, reset_rollback)):
        self._reset_on_return = reset_rollback
    elif (reset_on_return in (None, False, reset_none)):
        self._reset_on_return = reset_none
    elif (reset_on_return in ('commit', reset_commit)):
        self._reset_on_return = reset_commit
    else:
        raise exc.ArgumentError(("Invalid    value    for    'reset_on_return':    %r" % 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)
    if listeners:
        util.warn_deprecated("The    'listeners'    argument    to    Pool    (and    create_engine())    is    deprecated.        Use    event.listen().")
        for l in listeners:
            self.add_listener(l)
