Ejemplo n.º 1
0
 def test_thread_pool_stop_stopped(self):
     """Thread Pool is stopped after stop."""
     pool = ThreadPool(max_workers=1)
     pool.schedule(function, args=[1])
     pool.stop()
     pool.join()
     self.assertFalse(pool.active)
Ejemplo n.º 2
0
 def test_thread_pool_join_workers(self):
     """Thread Pool no worker is running after join."""
     pool = ThreadPool(max_workers=4)
     pool.schedule(function, args=[1])
     pool.stop()
     pool.join()
     self.assertEqual(len(pool._pool_manager.workers), 0)
Ejemplo n.º 3
0
 def test_thread_pool_join_workers(self):
     """Thread Pool no worker is running after join."""
     pool = ThreadPool(max_workers=4)
     pool.schedule(function, args=[1])
     pool.stop()
     pool.join()
     self.assertEqual(len(pool._pool_manager.workers), 0)
Ejemplo n.º 4
0
 def test_thread_pool_stop_stopped(self):
     """Thread Pool is stopped after stop."""
     pool = ThreadPool()
     pool.schedule(function, args=[1])
     pool.stop()
     pool.join()
     self.assertFalse(pool.active)
Ejemplo n.º 5
0
 def test_thread_pool_close_stopped(self):
     """Thread Pool is stopped after close."""
     pool = ThreadPool()
     pool.schedule(function, args=[1])
     pool.close()
     pool.join()
     self.assertFalse(pool.active)
Ejemplo n.º 6
0
 def test_thread_pool_close_stopped(self):
     """Thread Pool is stopped after close."""
     pool = ThreadPool(max_workers=1)
     pool.schedule(function, args=[1])
     pool.close()
     pool.join()
     self.assertFalse(pool.active)
Ejemplo n.º 7
0
 def test_thread_pool_join_futures_timeout(self):
     """Thread Pool TimeoutError is raised if join on long futures."""
     pool = ThreadPool(max_workers=1)
     for _ in range(2):
         pool.schedule(long_function)
     pool.close()
     self.assertRaises(TimeoutError, pool.join, 0.4)
     pool.stop()
     pool.join()
Ejemplo n.º 8
0
 def test_thread_pool_join_futures_timeout(self):
     """Thread Pool TimeoutError is raised if join on long futures."""
     pool = ThreadPool()
     for _ in range(2):
         pool.schedule(long_function)
     pool.close()
     self.assertRaises(TimeoutError, pool.join, 0.4)
     pool.stop()
     pool.join()
Ejemplo n.º 9
0
 def test_thread_pool_stop_futures(self):
     """Thread Pool not all futures are performed on stop."""
     futures = []
     pool = ThreadPool(max_workers=1)
     for index in range(10):
         futures.append(pool.schedule(long_function, args=[index]))
     pool.stop()
     pool.join()
     self.assertTrue(len([t for t in futures if not t.done()]) > 0)
Ejemplo n.º 10
0
 def test_thread_pool_close_futures(self):
     """Thread Pool all futures are performed on close."""
     futures = []
     pool = ThreadPool(max_workers=1)
     for index in range(10):
         futures.append(pool.schedule(function, args=[index]))
     pool.close()
     pool.join()
     map(self.assertTrue, [t.done() for t in futures])
Ejemplo n.º 11
0
 def test_thread_pool_stop_futures(self):
     """Thread Pool not all futures are performed on stop."""
     futures = []
     pool = ThreadPool()
     for index in range(10):
         futures.append(pool.schedule(long_function, args=[index]))
     pool.stop()
     pool.join()
     self.assertTrue(len([t for t in futures if not t.done()]) > 0)
Ejemplo n.º 12
0
 def test_thread_pool_close_futures(self):
     """Thread Pool all futures are performed on close."""
     futures = []
     pool = ThreadPool()
     for index in range(10):
         futures.append(pool.schedule(function, args=[index]))
     pool.close()
     pool.join()
     map(self.assertTrue, [t.done() for t in futures])