From: Irina Delamare Date: Thu, 24 Jan 2019 00:23:59 +0000 (-0500) Subject: Provide public accessor for Pool.timeout(). X-Git-Tag: rel_1_3_0b2~12^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f9c9f6453a7ed4b9ad01f6d4d808f5cd273f8290;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Provide public accessor for Pool.timeout(). Added public accessor :meth:`.Pool.timeout` that returns the configured timeout for a :class:`.Pool` object. Pull request courtesy Irina Delamare. Fixes: #3689 Closes: #4447 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4447 Pull-request-sha: 0179b0a829e9609429dc698992670d2e6749c10c Change-Id: I402b065cf9183160f71d9de73e308268356b7deb --- diff --git a/doc/build/changelog/unreleased_13/3689.rst b/doc/build/changelog/unreleased_13/3689.rst new file mode 100644 index 0000000000..80ab78d010 --- /dev/null +++ b/doc/build/changelog/unreleased_13/3689.rst @@ -0,0 +1,6 @@ +.. change:: + :tags: feature, engine + :tickets: 3689 + + Added public accessor :meth:`.Pool.timeout` that returns the configured + timeout for a :class:`.Pool` object. Pull request courtesy Irina Delamare. diff --git a/lib/sqlalchemy/pool/impl.py b/lib/sqlalchemy/pool/impl.py index ebbbfdb3d0..e1b948625a 100644 --- a/lib/sqlalchemy/pool/impl.py +++ b/lib/sqlalchemy/pool/impl.py @@ -201,6 +201,9 @@ class QueuePool(Pool): def size(self): return self._pool.maxsize + def timeout(self): + return self._timeout + def checkedin(self): return self._pool.qsize() diff --git a/test/engine/test_pool.py b/test/engine/test_pool.py index 75caa233af..672942482a 100644 --- a/test/engine/test_pool.py +++ b/test/engine/test_pool.py @@ -1130,6 +1130,12 @@ class QueuePoolTest(PoolTestBase): lazy_gc() assert not pool._refs + def test_timeout_accessor(self): + expected_timeout = 123 + p = self._queuepool_fixture( + timeout=expected_timeout) + eq_(p.timeout(), expected_timeout) + @testing.requires.timing_intensive def test_timeout(self): p = self._queuepool_fixture(pool_size=3, max_overflow=0, timeout=2)