summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing/assertions.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-07-22 12:54:39 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2014-07-22 12:55:17 -0400
commit76e127450c4bb7047a9babd5263a80e3c6f4cbf9 (patch)
tree9ba7b4802148e83d8f2b5deea2a3980d5d89af05 /lib/sqlalchemy/testing/assertions.py
parentb7021b698dcccde9c7d833cb561ee0abf7956178 (diff)
downloadsqlalchemy-76e127450c4bb7047a9babd5263a80e3c6f4cbf9.tar.gz
- allow 10 stray connections that need a gc
- be specific as to what occurred when we collect stray gc
Diffstat (limited to 'lib/sqlalchemy/testing/assertions.py')
-rw-r--r--lib/sqlalchemy/testing/assertions.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/sqlalchemy/testing/assertions.py b/lib/sqlalchemy/testing/assertions.py
index f9331a73e..79411af7e 100644
--- a/lib/sqlalchemy/testing/assertions.py
+++ b/lib/sqlalchemy/testing/assertions.py
@@ -154,8 +154,7 @@ def _assert_no_stray_pool_connections():
# there's a ref in there. usually just one.
if pool._refs:
- # OK, let's be somewhat forgiving. Increment a counter,
- # we'll allow a couple of these at most.
+ # OK, let's be somewhat forgiving.
_STRAY_CONNECTION_FAILURES += 1
print("Encountered a stray connection in test cleanup: %s"
@@ -168,7 +167,7 @@ def _assert_no_stray_pool_connections():
# if we've already had two of these occurrences, or
# after a hard gc sweep we still have pool._refs?!
# now we have to raise.
- if _STRAY_CONNECTION_FAILURES >= 2 or pool._refs:
+ if pool._refs:
err = str(pool._refs)
# but clean out the pool refs collection directly,
@@ -176,7 +175,11 @@ def _assert_no_stray_pool_connections():
# so the error doesn't at least keep happening.
pool._refs.clear()
_STRAY_CONNECTION_FAILURES = 0
- assert False, "Stray connections in cleanup: %s" % err
+ assert False, "Stray connection refused to leave "\
+ "after gc.collect(): %s" % err
+ elif _STRAY_CONNECTION_FAILURES > 10:
+ assert False, "Encountered more than 10 stray connections"
+ _STRAY_CONNECTION_FAILURES = 0
def eq_(a, b, msg=None):