diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-03-25 18:31:17 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-03-25 18:31:17 -0400 |
| commit | 8a776122a378f92a97a7bc5a54422a2fe1ecd8f9 (patch) | |
| tree | d590b415c88a478e4673f79a90ba059475570451 /lib/sqlalchemy/events.py | |
| parent | d594691a1af4e0d6b12aa4a5c1f1ede178a8985c (diff) | |
| download | sqlalchemy-8a776122a378f92a97a7bc5a54422a2fe1ecd8f9.tar.gz | |
- Added connection pool events :meth:`ConnectionEvents.close`,
:meth:`.ConnectionEvents.detach`,
:meth:`.ConnectionEvents.close_detached`.
Diffstat (limited to 'lib/sqlalchemy/events.py')
| -rw-r--r-- | lib/sqlalchemy/events.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/sqlalchemy/events.py b/lib/sqlalchemy/events.py index 1abef26d6..c679db37d 100644 --- a/lib/sqlalchemy/events.py +++ b/lib/sqlalchemy/events.py @@ -409,6 +409,46 @@ class PoolEvents(event.Events): """ + def close(self, dbapi_connection, connection_record): + """Called when a DBAPI connection is closed. + + The event is emitted before the close occurs. + + The close of a connection can fail; typically this is because + the connection is already closed. If the close operation fails, + the connection is discarded. + + The :meth:`.close` event corresponds to a connection that's still + associated with the pool. To intercept close events for detached + connections use :meth:`.close_detached`. + + .. versionadded:: 1.1 + + """ + + def detach(self, dbapi_connection, connection_record): + """Called when a DBAPI connection is "detached" from a pool. + + This event is emitted after the detach occurs. The connection + is no longer associated with the given connection record. + + .. versionadded:: 1.1 + + """ + + def close_detached(self, dbapi_connection): + """Called when a detached DBAPI connection is closed. + + The event is emitted before the close occurs. + + The close of a connection can fail; typically this is because + the connection is already closed. If the close operation fails, + the connection is discarded. + + .. versionadded:: 1.1 + + """ + class ConnectionEvents(event.Events): """Available events for :class:`.Connectable`, which includes |
