summaryrefslogtreecommitdiff
path: root/test/engine/test_pool.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-12-06 15:53:59 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2013-12-06 16:33:42 -0500
commit003b288b7644d8c39a13ac488ba56356c6375233 (patch)
treecb5229af2324623c358574e1fc46a320183cf01d /test/engine/test_pool.py
parentb653fb3a23a0388814d9ab79b884d64d396baff1 (diff)
downloadsqlalchemy-003b288b7644d8c39a13ac488ba56356c6375233.tar.gz
- Made a slight adjustment to the logic which waits for a pooled
connection to be available, such that for a connection pool with no timeout specified, it will every half a second break out of the wait to check for the so-called "abort" flag, which allows the waiter to break out in case the whole connection pool was dumped; normally the waiter should break out due to a notify_all() but it's possible this notify_all() is missed in very slim cases. This is an extension of logic first introduced in 0.8.0, and the issue has only been observed occasionally in stress tests.
Diffstat (limited to 'test/engine/test_pool.py')
-rw-r--r--test/engine/test_pool.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/test/engine/test_pool.py b/test/engine/test_pool.py
index c395dd825..3f05f661a 100644
--- a/test/engine/test_pool.py
+++ b/test/engine/test_pool.py
@@ -879,9 +879,14 @@ class QueuePoolTest(PoolTestBase):
handled when the pool is replaced.
"""
+ mutex = threading.Lock()
dbapi = MockDBAPI()
def creator():
- return dbapi.connect()
+ mutex.acquire()
+ try:
+ return dbapi.connect()
+ finally:
+ mutex.release()
success = []
for timeout in (None, 30):
@@ -903,11 +908,15 @@ class QueuePoolTest(PoolTestBase):
for i in range(2):
t = threading.Thread(target=waiter,
args=(p, timeout, max_overflow))
+ t.daemon = True
t.start()
threads.append(t)
- c1.invalidate()
- c2.invalidate()
+ # this sleep makes sure that the
+ # two waiter threads hit upon wait()
+ # inside the queue, before we invalidate the other
+ # two conns
+ time.sleep(.2)
p2 = p._replace()
for t in threads:
@@ -928,9 +937,7 @@ class QueuePoolTest(PoolTestBase):
p1 = pool.QueuePool(creator=creator1,
pool_size=1, timeout=None,
max_overflow=0)
- p2 = pool.QueuePool(creator=creator2,
- pool_size=1, timeout=None,
- max_overflow=-1)
+ p2 = pool.NullPool(creator=creator2)
def waiter(p):
conn = p.connect()
time.sleep(.5)