import asyncio from multiprocessing import Process from concurrent.futures import ProcessPoolExecutor import util @util.measure_performance def async_compute_task(): with ProcessPoolExecutor() as pool: futures = [pool.submit(util.compute_task) for _ in range(5)] for future in futures: future.result() @util.measure_performance_async async def async_io_task(): chunk_size = len(util.urls) // 5 chunks = [ util.urls[i:i + chunk_size] for i in range(0, len(util.urls), chunk_size) ] for chunk in chunks: tasks = [util.fetch_url_async(url) for url in chunk] await asyncio.gather(*tasks) def main(): async_compute_task() asyncio.run(async_io_task()) if __name__ == "__main__": main()