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)
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)
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()
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])
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()
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])