def test_shutdown(self): stopped = [0] def _worker(context): with context: while not context.stop_order: context.condition.wait() stopped[0] += 1 e = GenericExecutor("test", 6, _worker) e.start() e.stop() assert stopped[0] is 6
def test_executor_can_be_restarted(self): nb_threads = threading.active_count() def _dummy_worker(context): with context: while not context.stop_order: context.condition.wait() e = GenericExecutor("test", 6, _dummy_worker) # First start / stop with e: assert threading.active_count() is nb_threads + 6 assert threading.active_count() is nb_threads # Second start / stop e.start() assert threading.active_count() is nb_threads + 6 e.stop() assert threading.active_count() is nb_threads