def test_close(self, thread_pool: SimplePool): try: thread_pool.initial() thread_pool.async_apply(tasks_size=Task_Size, function=lambda a: a + a, args=(1, )) thread_pool.close() except Exception as e: assert False, "It should work finely without any issue. Please check it." else: assert True, "It work finely without any issue."
def test_close(self, simple_pool: SimplePool): try: simple_pool.initial() simple_pool.async_apply(tasks_size=Task_Size, function=lambda a: a + a, args=(1, )) simple_pool.close() except Exception: assert False, f"It should work finely without any issue. Please check it.\n Error: {traceback.format_exc()}" else: assert True, "It work finely without any issue."
# Import package multirunnable import pathlib import random import time import sys package_path = str(pathlib.Path(__file__).parent.parent.parent.absolute()) sys.path.append(package_path) from multirunnable import SimplePool, RunningMode def function(index): print(f"This isfunction with index {index}") time.sleep(3) return "Return Value" pool = SimplePool(mode=RunningMode.Parallel, pool_size=3) pool.initial() pool.async_apply(function=function, kwargs={"index": f"test_{random.randrange(1, 10)}"}, tasks_size=3) pool.close() result = pool.get_result() print(f"This is final result: {result}")