diff options
| author | Jason Kirtland <jek@discorporate.us> | 2009-07-10 21:48:45 +0000 |
|---|---|---|
| committer | Jason Kirtland <jek@discorporate.us> | 2009-07-10 21:48:45 +0000 |
| commit | ca4744c1cb0fcd9888a45f50ecbc5b4549f3a637 (patch) | |
| tree | 96c50a6024815cedf48859cd0d0d14415a9781d3 | |
| parent | 910961fccdf9fe6933c56c595c1126df132a31ff (diff) | |
| download | sqlalchemy-ca4744c1cb0fcd9888a45f50ecbc5b4549f3a637.tar.gz | |
Implemented recreate() for StaticPool
| -rw-r--r-- | CHANGES | 6 | ||||
| -rw-r--r-- | lib/sqlalchemy/pool.py | 16 | ||||
| -rw-r--r-- | test/engine/test_pool.py | 12 |
3 files changed, 27 insertions, 7 deletions
@@ -84,7 +84,11 @@ CHANGES incompatible change for any application that may have been using this feature, however the feature has never been documented. - + +- engine/pool + - Implemented recreate() for StaticPool. + + 0.5.4p2 ======= diff --git a/lib/sqlalchemy/pool.py b/lib/sqlalchemy/pool.py index 2eabd8572..c4e1af20c 100644 --- a/lib/sqlalchemy/pool.py +++ b/lib/sqlalchemy/pool.py @@ -706,15 +706,16 @@ class NullPool(Pool): def dispose(self): pass - + + class StaticPool(Pool): """A Pool of exactly one connection, used for all requests. - + Reconnect-related functions such as ``recycle`` and connection invalidation (which is also used to support auto-reconnect) are not currently supported by this Pool implementation but may be implemented in a future release. - + """ def __init__(self, creator, **params): @@ -754,6 +755,15 @@ class StaticPool(Pool): self._conn.close() self._conn = None + def recreate(self): + self.log("Pool recreating") + return self.__class__(creator=self._creator, + recycle=self._recycle, + use_threadlocal=self._use_threadlocal, + reset_on_return=self._reset_on_return, + echo=self.echo, + listeners=self.listeners) + def create_connection(self): return self._conn diff --git a/test/engine/test_pool.py b/test/engine/test_pool.py index 43a0fc38b..d135ad337 100644 --- a/test/engine/test_pool.py +++ b/test/engine/test_pool.py @@ -659,6 +659,12 @@ class NullPoolTest(PoolTestBase): c1 = p.connect() assert c1.connection.id != c_id - - - + + +class StaticPoolTest(PoolTestBase): + def test_recreate(self): + dbapi = MockDBAPI() + creator = lambda: dbapi.connect('foo.db') + p = pool.StaticPool(creator) + p2 = p.recreate() + assert p._creator is p2._creator |
