def test_doing_work_with_one_worker(self): config = DotDict() config.logger = self.logger config.number_of_threads = 1 config.maximum_queue_size = 1 my_list = [] def insert_into_list(anItem): my_list.append(anItem) ttm = ThreadedTaskManager(config, task_func=insert_into_list ) try: ttm.start() time.sleep(0.2) ok_(len(my_list) == 10, 'expected to do 10 inserts, ' 'but %d were done instead' % len(my_list)) ok_(my_list == range(10), 'expected %s, but got %s' % (range(10), my_list)) ttm.stop() except Exception: # we got threads to join ttm.wait_for_completion() raise
def test_doing_work_with_one_worker(self): config = DotDict() config.logger = self.logger config.number_of_threads = 1 config.maximum_queue_size = 1 my_list = [] def insert_into_list(anItem): my_list.append(anItem) ttm = ThreadedTaskManager(config, task_func=insert_into_list ) try: ttm.start() time.sleep(0.2) ok_(len(my_list) == 10, 'expected to do 10 inserts, ' 'but %d were done instead' % len(my_list)) ok_(my_list == range(10), 'expected %s, but got %s' % (range(10), my_list)) ttm.stop() except Exception: # we got threads to join ttm.wait_for_completion() raise
def test_start1(self): config = DotDict() config.number_of_threads = 1 config.maximum_queue_size = 1 ttm = ThreadedTaskManager(config) try: ttm.start() time.sleep(0.2) assert ttm.queuing_thread.isAlive(), "the queing thread is not running" assert len(ttm.thread_list) == 1, "where's the worker thread?" assert ttm.thread_list[0].isAlive(), "the worker thread is stillborn" ttm.stop() assert not ttm.queuing_thread.isAlive(), "the queuing thread did not stop" except Exception: # we got threads to join ttm.wait_for_completion()
def test_doing_work_with_one_worker(self): config = DotDict() config.number_of_threads = 1 config.maximum_queue_size = 1 my_list = [] def insert_into_list(anItem): my_list.append(anItem) ttm = ThreadedTaskManager(config, task_func=insert_into_list) try: ttm.start() time.sleep(0.2) assert len(my_list) == 10 assert my_list == list(range(10)) ttm.stop() except Exception: # we got threads to join ttm.wait_for_completion() raise
def test_doing_work_with_one_worker(self): config = DotDict() config.number_of_threads = 1 config.maximum_queue_size = 1 my_list = [] def insert_into_list(anItem): my_list.append(anItem) ttm = ThreadedTaskManager(config, task_func=insert_into_list) try: ttm.start() time.sleep(0.2) assert len(my_list) == 10 assert my_list == list(range(10)) ttm.stop() except Exception: # we got threads to join ttm.wait_for_completion() raise