gray0
107 天前
何必多 BB 直接上代码
from concurrent.futures import ProcessPoolExecutor
import asyncio
async def integration_process_and_gather():
with ProcessPoolExecutor() as process_pool:
loop = asyncio.get_running_loop()
numbers = [100000000, 1, 100, 10000, 1000000, 1000, 100000]
tasks = [
loop.run_in_executor(process_pool, do_count_number, n) for n in numbers
]
[print(type(task)) for task in tasks]
results = await asyncio.gather(*tasks)
print(f"integration_hello_world {results}")