def test_thread_pool_daemon_flag(): thread_pool = ThreadPool(2, "TestThreadPoolDaemonFlag", daemon=True, polling_timeout=1) created_threads = testutil.get_threads_with_name("TestThreadPoolDaemonFlag") # print len(created_threads) thread_name, thread_obj = created_threads.popitem() assert thread_obj.daemon is True thread_pool.terminate()
def test_thread_pool_thread_limitation(): thread_pool = ThreadPool(5, "TestThreadPoolLimitation", polling_timeout=1) i = 0 counter_queue = Queue() while i < 10: thread_pool.enqueue(EasyTask(lambda(l): counter_queue.put(l), "Test%s" % i)) i += 1 assert len(testutil.get_threads_with_name("TestThreadPoolLimitation")) == 5 thread_pool.terminate() assert counter_queue.qsize() == 10
def test_thread_pool_daemon_flag(): thread_pool = ThreadPool(2, "TestThreadPoolDaemonFlag", daemon=True, polling_timeout=1) created_threads = testutil.get_threads_with_name( "TestThreadPoolDaemonFlag") # print len(created_threads) thread_name, thread_obj = created_threads.popitem() assert thread_obj.daemon is True thread_pool.terminate()
def test_thread_pool_thread_limitation(): thread_pool = ThreadPool(5, "TestThreadPoolLimitation", polling_timeout=1) i = 0 counter_queue = Queue() while i < 10: thread_pool.enqueue( EasyTask(lambda (l): counter_queue.put(l), "Test%s" % i)) i += 1 assert len(testutil.get_threads_with_name("TestThreadPoolLimitation")) == 5 thread_pool.terminate() assert counter_queue.qsize() == 10
def test_thread_pool_pool_thread_size(): thread_pool = ThreadPool(5, "TestThreadPoolSize", polling_timeout=1) live_threads = testutil.get_threads_with_name("TestThreadPoolSize") assert len(live_threads.keys()) == 5 thread_pool.terminate()