我目前正在通过基于for循环长度的线程池执行任务,并且当它不应该(在循环结束之前)结束它的执行。有什么想法吗?这是相关代码:
from classes.scraper import size
from multiprocessing import Pool
import threading
if __name__ == '__main__':
print("Do something")
size = size()
pool = Pool(processes=50)
with open('size.txt','r') as file:
asf = file.read()
for x in range(0,1000000):
if '{num:06d}'.format(num=x) in asf:
continue
else:
res = pool.apply_async(size.scrape, ('{num:06d}'.format(num=x),))
这是控制台输出(我打印出size.scrape()
内的值。
...
...
...
013439
013440
013441
013442
013443
Process finished with exit code 0