diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-06-06 17:50:32 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-06-06 17:50:32 -0400 |
| commit | 54b15aaf37917c946e3f4fa45cc1262e14b22ef4 (patch) | |
| tree | a825d83616e3d3f44abb12c1303d1107c228be92 /lib/sqlalchemy | |
| parent | 4e6ec9eef4e65c6efabae36b2307f2ad167977da (diff) | |
| download | sqlalchemy-54b15aaf37917c946e3f4fa45cc1262e14b22ef4.tar.gz | |
- Added new engine event :meth:`.ConnectionEvents.engine_disposed`.
Called after the :meth:`.Engine.dispose` method is called.
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/engine/base.py | 1 | ||||
| -rw-r--r-- | lib/sqlalchemy/events.py | 17 |
2 files changed, 18 insertions, 0 deletions
diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index 7ebe39bbf..59754a436 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -1834,6 +1834,7 @@ class Engine(Connectable, log.Identified): """ self.pool.dispose() self.pool = self.pool.recreate() + self.dispatch.engine_disposed(self) def _execute_default(self, default): with self.contextual_connect() as conn: diff --git a/lib/sqlalchemy/events.py b/lib/sqlalchemy/events.py index b2d4b54a9..f439d554f 100644 --- a/lib/sqlalchemy/events.py +++ b/lib/sqlalchemy/events.py @@ -882,6 +882,23 @@ class ConnectionEvents(event.Events): """ + def engine_disposed(self, engine): + """Intercept when the :meth:`.Engine.dispose` method is called. + + The :meth:`.Engine.dispose` method instructs the engine to + "dispose" of it's connection pool (e.g. :class:`.Pool`), and + replaces it with a new one. Disposing of the old pool has the + effect that existing checked-in connections are closed. The new + pool does not establish any new connections until it is first used. + + This event can be used to indicate that resources related to the + :class:`.Engine` should also be cleaned up, keeping in mind that the + :class:`.Engine` can still be used for new requests in which case + it re-acquires connection resources. + + .. versionadded:: 1.0.5 + + """ def begin(self, conn): """Intercept begin() events. |
