summaryrefslogtreecommitdiff
path: root/test/engine/test_pool.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-03-26 16:31:52 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2014-03-26 16:31:52 -0400
commit761c8ff15de16e572a6e1382cae76d734bd411e7 (patch)
tree206e5f7666adf2754bf77c5719206282441bf1a3 /test/engine/test_pool.py
parentdc0d581d5d10589e02d8d38698afb470559d22f2 (diff)
downloadsqlalchemy-761c8ff15de16e572a6e1382cae76d734bd411e7.tar.gz
- work on fixing some race-condition failures:
1. make sure pool._invalidate() sets the timestamp up before invalidating the target connection. we can otherwise show how the conn.invalidate() + pool._invalidate() can lead to an extra connection being made. 2. to help with that, soften up the check on connection.invalidate() when connection is already closed. a warning is fine here 3. add a mutex to test_max_overflow() when we connect, because the way we're using mock depends on an iterator, that needs to be synchronized
Diffstat (limited to 'test/engine/test_pool.py')
-rw-r--r--test/engine/test_pool.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/test/engine/test_pool.py b/test/engine/test_pool.py
index a6f40d992..a9e650cca 100644
--- a/test/engine/test_pool.py
+++ b/test/engine/test_pool.py
@@ -912,9 +912,11 @@ class QueuePoolTest(PoolTestBase):
gc_collect()
dbapi = MockDBAPI()
+ mutex = threading.Lock()
def creator():
time.sleep(.05)
- return dbapi.connect()
+ with mutex:
+ return dbapi.connect()
p = pool.QueuePool(creator=creator,
pool_size=3, timeout=2,
@@ -1070,7 +1072,6 @@ class QueuePoolTest(PoolTestBase):
# two conns
time.sleep(.2)
p._invalidate(c2)
- c2.invalidate()
for t in threads:
t.join(join_timeout)
@@ -1088,7 +1089,6 @@ class QueuePoolTest(PoolTestBase):
p1 = pool.QueuePool(creator=creator,
pool_size=1, timeout=None,
max_overflow=0)
- #p2 = pool.NullPool(creator=creator2)
def waiter(p):
conn = p.connect()
canary.append(2)
@@ -1105,7 +1105,8 @@ class QueuePoolTest(PoolTestBase):
time.sleep(.5)
eq_(canary, [1])
- c1.invalidate()
+ # this also calls invalidate()
+ # on c1
p1._invalidate(c1)
for t in threads: