diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-09-14 20:43:48 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-09-14 20:43:48 -0400 |
| commit | 3d389b19b70b65cb76226c3f3aa4c5d926e1f12b (patch) | |
| tree | bdc597ebf2786f0514c8029dd2dbe2385bb9c2df /lib/sqlalchemy/pool.py | |
| parent | 60b82d6e13246a3d88e7288e863a5231b7572c6a (diff) | |
| download | sqlalchemy-3d389b19b70b65cb76226c3f3aa4c5d926e1f12b.tar.gz | |
- reorganization
- attrbutes.py splits into attribtes.py and instrumentation.py
- all the various Event subclasses go into events.py modules
- some ideas for orm events
- move *Extension out to deprecated_interfaces
Diffstat (limited to 'lib/sqlalchemy/pool.py')
| -rw-r--r-- | lib/sqlalchemy/pool.py | 79 |
1 files changed, 2 insertions, 77 deletions
diff --git a/lib/sqlalchemy/pool.py b/lib/sqlalchemy/pool.py index 9ed5c8067..7d9166205 100644 --- a/lib/sqlalchemy/pool.py +++ b/lib/sqlalchemy/pool.py @@ -19,7 +19,7 @@ SQLAlchemy connection pool. import weakref, time, threading -from sqlalchemy import exc, log, event, interfaces, util +from sqlalchemy import exc, log, event, events, interfaces, util from sqlalchemy import queue as sqla_queue from sqlalchemy.util import threading, pickle, memoized_property @@ -57,81 +57,6 @@ def clear_managers(): manager.close() proxies.clear() -class PoolEvents(event.Events): - """Available events for :class:`.Pool`. - - The methods here define the name of an event as well - as the names of members that are passed to listener - functions. - - e.g.:: - - from sqlalchemy import events - - def my_on_checkout(dbapi_conn, connection_rec, connection_proxy): - "handle an on checkout event" - - events.listen(my_on_checkout, 'on_checkout', Pool) - - """ - - def on_connect(self, dbapi_connection, connection_record): - """Called once for each new DB-API connection or Pool's ``creator()``. - - :param dbapi_con: - A newly connected raw DB-API connection (not a SQLAlchemy - ``Connection`` wrapper). - - :param con_record: - The ``_ConnectionRecord`` that persistently manages the connection - - """ - - def on_first_connect(self, dbapi_connection, connection_record): - """Called exactly once for the first DB-API connection. - - :param dbapi_con: - A newly connected raw DB-API connection (not a SQLAlchemy - ``Connection`` wrapper). - - :param con_record: - The ``_ConnectionRecord`` that persistently manages the connection - - """ - - def on_checkout(self, dbapi_connection, connection_record, connection_proxy): - """Called when a connection is retrieved from the Pool. - - :param dbapi_con: - A raw DB-API connection - - :param con_record: - The ``_ConnectionRecord`` that persistently manages the connection - - :param con_proxy: - The ``_ConnectionFairy`` which manages the connection for the span of - the current checkout. - - If you raise an ``exc.DisconnectionError``, the current - connection will be disposed and a fresh connection retrieved. - Processing of all checkout listeners will abort and restart - using the new connection. - """ - - def on_checkin(self, dbapi_connection, connection_record): - """Called when a connection returns to the pool. - - Note that the connection may be closed, and may be None if the - connection has been invalidated. ``checkin`` will not be called - for detached connections. (They do not return to the pool.) - - :param dbapi_con: - A raw DB-API connection - - :param con_record: - The ``_ConnectionRecord`` that persistently manages the connection - - """ class Pool(log.Identified): """Abstract base class for connection pools.""" @@ -209,7 +134,7 @@ class Pool(log.Identified): for l in listeners: self.add_listener(l) - dispatch = event.dispatcher(PoolEvents) + dispatch = event.dispatcher(events.PoolEvents) @util.deprecated(2.7, "Pool.add_listener is deprecated. Use event.listen()") def add_listener(self, listener): |
