]> 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:35:11 +0000 (14:35 -0500)
- use thread.join() for waiters_handled test

test/engine/test_pool.py

index d5d384948a7120a244ae62e910a62f187c56b146..a59a040d6561616a3511862e0405cd5ec414a0c5 100644 (file)
@@ -10,6 +10,8 @@ from sqlalchemy.testing import fixtures
 
 from sqlalchemy.testing.mock import Mock, call
 
+join_timeout = 10
+
 def MockDBAPI():
     def cursor():
         while True:
@@ -827,7 +829,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:
@@ -864,7 +866,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)
 
@@ -897,16 +899,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(.5)
+
+                for t in threads:
+                    t.join(join_timeout)
 
         eq_(len(success), 12, "successes: %s" % success)
 
@@ -1245,7 +1250,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: