diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-03-13 13:53:31 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-03-13 13:53:31 -0500 |
| commit | 5f1fbf575915470391c5a816d99a742e64b6be25 (patch) | |
| tree | e47cc04988a835ef03f1b3bb02e5a5c4d0495e24 /lib/sqlalchemy/pool.py | |
| parent | 3290ac23df9eed8a61324eb68f062a7de29e549d (diff) | |
| download | sqlalchemy-5f1fbf575915470391c5a816d99a742e64b6be25.tar.gz | |
- Added "logging_name" argument to create_engine(), Pool() constructor
as well as "pool_logging_name" argument to create_engine() which
filters down to that of Pool. Issues the given string name
within the "name" field of logging messages instead of the default
hex identifier string. [ticket:1555]
Diffstat (limited to 'lib/sqlalchemy/pool.py')
| -rw-r--r-- | lib/sqlalchemy/pool.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/sqlalchemy/pool.py b/lib/sqlalchemy/pool.py index 8d6ae3292..3be63ced3 100644 --- a/lib/sqlalchemy/pool.py +++ b/lib/sqlalchemy/pool.py @@ -56,12 +56,13 @@ def clear_managers(): manager.close() proxies.clear() -class Pool(object): +class Pool(log.Identified): """Abstract base class for connection pools.""" def __init__(self, creator, recycle=-1, echo=None, use_threadlocal=False, + logging_name=None, reset_on_return=True, listeners=None): """ Construct a Pool. @@ -75,6 +76,11 @@ class Pool(object): 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 @@ -102,6 +108,8 @@ class Pool(object): pool. """ + if logging_name: + self.logging_name = logging_name self.logger = log.instance_logger(self, echoflag=echo) self._threadconns = threading.local() self._creator = creator @@ -477,9 +485,9 @@ class SingletonThreadPool(Pool): """ - def __init__(self, creator, pool_size=5, **params): - params['use_threadlocal'] = True - Pool.__init__(self, creator, **params) + def __init__(self, creator, pool_size=5, **kw): + kw['use_threadlocal'] = True + Pool.__init__(self, creator, **kw) self._conn = threading.local() self._all_conns = set() self.size = pool_size |
