function_1 called function_2 called function_3 called function_1 called function_2 called function_3 called function_1 called function_2 called function_3 called
# 2. 在指定的thread pool中执行 with concurrent.futures.ThreadPoolExecutor() as pool: result = await loop.run_in_executor( pool, blocking_io) print('custom thread pool', result)
# 3. 在指定的process pool中执行 with concurrent.futures.ProcessPoolExecutor() as pool: result = await loop.run_in_executor( pool, cpu_bound) print('custom process pool', result)
if __name__ == '__main__': asyncio.run(main())
# 输出: # default thread pool 11 # custom thread pool 11 # custom process pool 333333283333335000000