首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Concurrent.futures问题

Concurrent.futures问题
EN

Stack Overflow用户
提问于 2021-05-04 04:00:27
回答 1查看 182关注 0票数 0

因此,我有需要使用Concurrent.futures模块的代码,出于某种原因,它告诉我它不存在。我已经查过了,我找不到问题所在。我试着安装我需要的工具,以为是这样的,但我只能下载其中一个工具。错误消息:

从concurrent.futures导入ProcessPoolExecutor ModuleNotFoundError:没有一个模块名为“concurrent.fusion”;“并发”不是一个包

我的代码:

代码语言:javascript
复制
import requests, time
from concurrent.futures import ProcessPoolExecutor

sites = ["http://www.youtube.com"]

def get_one(site):
    resp = requests.get(site)
    size = len(resp.content)
    print(f"download {site} bytes from {site}")
    return size

def main():
    total_size = 0
    start = time.perf_counter()
    with ProcessPoolExecutor as exec:
        total_size = sum(exec.map(get_one, sites))
    end = time.perf_counter()
    for site in sites:
        
        total_size += size
        #print(f"downlded {size} bytes from {site}")
    #end = time.perf_counter()
    
    print(f"elapsed time: {end - start} seconds")
    print (f"downloaded a totla of {total_size} bytes")
    
    
if __name__== "__main__":
    main()

我知道当我说“开始”的时候,通常应该有一个文件,但是我查到的所有东西都说concurrent.futures是python的一部分,但出于某种原因,我的文件不能正常工作。如果它在外面,我必须安装它吗?

EN

回答 1

Stack Overflow用户

发布于 2021-05-04 15:40:22

我发现我的文件夹中有一个名为concurrent.py的文件,它把一切都搞砸了!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67378624

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档