]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- apply a timeout to all join() calls for test_pool
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 17 Nov 2013 19:35:11 +0000 (14:35 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 17 Nov 2013 19:38:11 +0000 (14:38 -0500)
- use thread.join() for waiters_handled test

Conflicts:
test/engine/test_pool.py

test/engine/test_pool.py

index 84eb3f65684f0509c71fe611251c7047df016d14..a261a2aebb6586aae34c5f6717020351c9d234c6 100644 (file)
@@ -12,6 +12,8 @@ from sqlalchemy.testing import fixtures
 
 from sqlalchemy.testing.mock import Mock, call
 
+join_timeout = 10
+
 def MockDBAPI():
     def cursor():
         while True:
@@ -829,7 +831,7 @@ class QueuePoolTest(PoolTestBase):
             th.start()
             threads.append(th)
         for th in threads:
-            th.join()
+            th.join(join_timeout)
 
         assert len(timeouts) > 0
         for t in timeouts:
@@ -866,7 +868,7 @@ class QueuePoolTest(PoolTestBase):
             th.start()
             threads.append(th)
         for th in threads:
-            th.join()
+            th.join(join_timeout)
 
         self.assert_(max(peaks) <= max_overflow)
 
@@ -899,16 +901,19 @@ class QueuePoolTest(PoolTestBase):
                 c1 = p.connect()
                 c2 = p.connect()
 
+                threads = set()
                 for i in range(2):
                     t = threading.Thread(target=waiter,
                                     args=(p, timeout, max_overflow))
-                    t.setDaemon(True)  # so the tests dont hang if this fails
                     t.start()
+                    threads.add(t)
 
                 c1.invalidate()
                 c2.invalidate()
                 p2 = p._replace()
-                time.sleep(.2)
+
+                for t in threads:
+                    t.join(join_timeout)
 
         eq_(len(success), 12, "successes: %s" % success)
 
@@ -1248,7 +1253,7 @@ class SingletonThreadPoolTest(PoolTestBase):
             th.start()
             threads.append(th)
         for th in threads:
-            th.join()
+            th.join(join_timeout)
         assert len(p._all_conns) == 3
 
         if strong_refs: