Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
与Python中的多处理相比,concurrent.futures有哪些优势?_Python_Multithreading_Multiprocessing_Concurrent.futures - Fatal编程技术网

与Python中的多处理相比,concurrent.futures有哪些优势?

与Python中的多处理相比,concurrent.futures有哪些优势?,python,multithreading,multiprocessing,concurrent.futures,Python,Multithreading,Multiprocessing,Concurrent.futures,我正在用Python编写一个应用程序,需要同时运行一些任务。模块multiprocessing提供类Process,concurrent.futures模块具有类ProcessPoolExecutor。两者似乎都使用多个进程来执行任务,但它们的API不同。为什么我要用一个而不是另一个 我知道在Python3中添加了concurrent.futures,所以我想它会更好?concurrent.futures的动机将在中介绍 根据我的实践经验,concurrent.futures为长时间运行的任务提

我正在用Python编写一个应用程序,需要同时运行一些任务。模块multiprocessing提供类Process,concurrent.futures模块具有类ProcessPoolExecutor。两者似乎都使用多个进程来执行任务,但它们的API不同。为什么我要用一个而不是另一个


我知道在Python3中添加了concurrent.futures,所以我想它会更好?

concurrent.futures的动机将在中介绍

根据我的实践经验,concurrent.futures为长时间运行的任务提交和监视情况提供了更方便的编程模型。我最近使用concurrent.futures编写了一个程序,该程序在2-3个小时的时间内监视一个目录中的传入文件,在每个文件到达任务时对其进行翻译,然后提交,等等。ProcessPoolExecutor返回的未来对象允许跟踪任务状态,以方便的方式提供中间状态报告等。

重复,但不应关闭,因为答案提供了其他地方不可用的详细信息。