diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-01-14 18:07:14 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-01-15 00:29:12 -0500 |
commit | 44034f19ac27ccd4a0e57dfa3d2d6b494dc9b133 (patch) | |
tree | 9837f4818d8e345fc36fe99cd888825832a6b98e /test/engine/test_pool.py | |
parent | 41ca37734aa4f293ac5fb63c239d78185c8ec983 (diff) | |
download | sqlalchemy-44034f19ac27ccd4a0e57dfa3d2d6b494dc9b133.tar.gz |
Create explicit GC ordering between ConnectionFairy/ConnectionRecord
Fixed issue where connection pool would not return connections to the pool
or otherwise be finalized upon garbage collection under pypy if the checked
out connection fell out of scope without being closed. This is a long
standing issue due to pypy's difference in GC behavior that does not call
weakref finalizers if they are relative to another object that is also
being garbage collected. A strong reference to the related record is now
maintained so that the weakref has a strong-referenced "base" to trigger
off of.
Fixes: #5842
Change-Id: Id5448fdacb6cceaac1ea40b2fbc851f052ed8e86
Diffstat (limited to 'test/engine/test_pool.py')
-rw-r--r-- | test/engine/test_pool.py | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/test/engine/test_pool.py b/test/engine/test_pool.py index decdce3f9..b43a29fae 100644 --- a/test/engine/test_pool.py +++ b/test/engine/test_pool.py @@ -259,7 +259,6 @@ class PoolTest(PoolTestBase): d2.pop(k, None) for k in ( - "_threadconns", "_invoke_creator", "_pool", "_overflow_lock", @@ -639,7 +638,6 @@ class PoolEventsTest(PoolTestBase): assert canary.call_args_list[0][0][2] is exc @testing.combinations((True, testing.requires.python3), (False,)) - @testing.requires.predictable_gc def test_checkin_event_gc(self, detach_gced): p, canary = self._checkin_event_fixture() @@ -848,8 +846,6 @@ class QueuePoolTest(PoolTestBase): def _do_testqueuepool(self, useclose=False): p = self._queuepool_fixture(pool_size=3, max_overflow=-1) - reaper = testing.engines.ConnectionKiller() - reaper.add_pool(p) def status(pool): return ( @@ -878,7 +874,7 @@ class QueuePoolTest(PoolTestBase): else: c4 = c3 = c2 = None lazy_gc() - self.assert_(status(p) == (3, 3, 3, 3)) + eq_(status(p), (3, 3, 3, 3)) if useclose: c1.close() c5.close() @@ -898,8 +894,6 @@ class QueuePoolTest(PoolTestBase): self.assert_(status(p) == (3, 2, 0, 1)) c1.close() - reaper.assert_all_closed() - def test_timeout_accessor(self): expected_timeout = 123 p = self._queuepool_fixture(timeout=expected_timeout) @@ -1391,6 +1385,7 @@ class QueuePoolTest(PoolTestBase): dbapi.shutdown(True) assert_raises_context_ok(Exception, p.connect) eq_(p._overflow, 0) + eq_(p.checkedout(), 0) # and not 1 dbapi.shutdown(False) @@ -1520,7 +1515,6 @@ class QueuePoolTest(PoolTestBase): self._assert_cleanup_on_pooled_reconnect(dbapi, p) @testing.combinations((True, testing.requires.python3), (False,)) - @testing.requires.predictable_gc def test_userspace_disconnectionerror_weakref_finalizer(self, detach_gced): dbapi, pool = self._queuepool_dbapi_fixture( pool_size=1, max_overflow=2 |