summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing/engines.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2020-02-01 12:27:09 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2020-02-01 13:12:57 -0500
commitc797056413230cc5c11bc458e5f7760063c2682e (patch)
tree58a7cebda24e574aafe4a04b1258680248ed59fd /lib/sqlalchemy/testing/engines.py
parent2df647cd7590ae31b542256a5036d2ff49f321aa (diff)
downloadsqlalchemy-c797056413230cc5c11bc458e5f7760063c2682e.tar.gz
Do away with pool._refs
This collection was added only for the benefit of unit tests and is unnecessary for the pool to function. As SQLAlchemy 2.0 will be removing the automatic handling of connections that are garbage collection, remove this collection so that we ultimately don't need a weakref handler to do anything within the pool. The handler will do nothing other than emit a warning that a connection was dereferenced without being explicitly returned to the pool, invalidated, or detached. Change-Id: I4ca196270d5714efbac44dbf6f034e8c7f0af58a
Diffstat (limited to 'lib/sqlalchemy/testing/engines.py')
-rw-r--r--lib/sqlalchemy/testing/engines.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/sqlalchemy/testing/engines.py b/lib/sqlalchemy/testing/engines.py
index ff4f89606..4f413915a 100644
--- a/lib/sqlalchemy/testing/engines.py
+++ b/lib/sqlalchemy/testing/engines.py
@@ -12,7 +12,6 @@ import warnings
import weakref
from . import config
-from . import uses_deprecated
from .util import decorator
from .. import event
from .. import pool
@@ -24,7 +23,13 @@ class ConnectionKiller(object):
self.testing_engines = weakref.WeakKeyDictionary()
self.conns = set()
+ def add_pool(self, pool):
+ event.listen(pool, "connect", self.connect)
+ event.listen(pool, "checkout", self.checkout)
+ event.listen(pool, "invalidate", self.invalidate)
+
def add_engine(self, engine):
+ self.add_pool(engine.pool)
self.testing_engines[engine] = True
def connect(self, dbapi_conn, con_record):
@@ -75,7 +80,6 @@ class ConnectionKiller(object):
else:
self._stop_test_ctx_aggressive()
- @uses_deprecated()
def _stop_test_ctx_minimal(self):
self.close_all()
@@ -85,7 +89,6 @@ class ConnectionKiller(object):
if rec is not config.db:
rec.dispose()
- @uses_deprecated()
def _stop_test_ctx_aggressive(self):
self.close_all()
for conn, rec in list(self.conns):
@@ -265,9 +268,6 @@ def testing_engine(url=None, options=None):
engine.pool._timeout = 0
engine.pool._max_overflow = 0
if use_reaper:
- event.listen(engine.pool, "connect", testing_reaper.connect)
- event.listen(engine.pool, "checkout", testing_reaper.checkout)
- event.listen(engine.pool, "invalidate", testing_reaper.invalidate)
testing_reaper.add_engine(engine)
return engine