summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2017-04-27 17:44:29 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2017-04-27 17:44:29 -0400
commitcedb11925fc7dd652f479370b59c38324e0e3951 (patch)
tree1fbbf749428946a803b3785dcfcfe342b7680b39
parent433d2ee9f14a028399e848f3552a1a71f223c976 (diff)
downloadsqlalchemy-cedb11925fc7dd652f479370b59c38324e0e3951.tar.gz
- keep trying to identify the race here. can reproduce locally
now and it seems like mock might not be doing the right thing. Change-Id: I5c108d82631c9217da54a8ace68d7728c3e204d8
-rw-r--r--test/engine/test_pool.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/test/engine/test_pool.py b/test/engine/test_pool.py
index ffbb5f282..9572d3a24 100644
--- a/test/engine/test_pool.py
+++ b/test/engine/test_pool.py
@@ -20,7 +20,16 @@ def MockDBAPI(): # noqa
return Mock()
def connect(*arg, **kw):
- return Mock(cursor=Mock(side_effect=cursor))
+ def close():
+ conn.closed = True
+
+ # mock seems like it might have an issue logging
+ # call_count correctly under threading, not sure.
+ # adding a side_effect for close seems to help.
+ conn = Mock(
+ cursor=Mock(side_effect=cursor),
+ close=Mock(side_effect=close), closed=False)
+ return conn
def shutdown(value):
if value:
@@ -2016,21 +2025,12 @@ class SingletonThreadPoolTest(PoolTestBase):
return dbapi.connect()
p = pool.SingletonThreadPool(creator=creator, pool_size=3)
- # there's an obvious race in STP which is that one thread
- # creates a connection, another one calls cleanup and closes
- # it before it ever gets returned. This is of course if you're
- # using more threads than the pool can connect to.
-
if strong_refs:
sr = set()
def _conn():
c = p.connect()
- if not c.connection.close.call_count:
- sr.add(c.connection)
- # otherwise the connection is already closed, which
- # is because you're using 10 threads but only a pool
- # of size 3 :).
+ sr.add(c.connection)
return c
else:
def _conn():