标签:spool tor exe func 大数 down time sleep 模块
from concurrent.futures import ThreadPoolExecutor
from time import sleep
tpool = ThreadPoolExecutor(max_workers=5) #设置线程最大数量
def func(i):
sleep(1)
print(i)
for i in range(20):
tpool.submit(func, i)
tpool.shutdown() #等待所有子线程运行结束
print(‘主线程在这里‘)
t.result()
获取函数的返回值from concurrent.futures import ProcessPoolExecutor
from time import sleep
tpool = ProcessPoolExecutor(max_workers=5) #这是最大进程数
def func(i):
sleep(1)
print(i)
for i in range(20):
tpool.submit(func, i)
tpool.shutdown() #等待所有子进程运行结束
print(‘主线程在这里‘)
- `t.result() ` 获取函数的返回值
标签:spool tor exe func 大数 down time sleep 模块
原文地址:https://www.cnblogs.com/liliudong/p/9742489.html