我想在AirSpider爬虫中的parse函数中使用ThreadPoolExecutor线程池实现并发下载图片,但是会报错误:|cannot schedule new futures after interpreter shutdown。
我的python是3.10.
代码类似下面:
def parse(self, request, response):
with ThreadPoolExecutor(max_workers=10) as executor:
tasks = []
for i in range(1, 10):
tasks.append(executor.submit(math.sqrt, i))
for future in tasks:
print(future.result())
请问大佬这是什么原因?如果我想实现图片并发下载该如何实现(我想把下载后的图片路径写入item中)