小菜鸡请教 concurrent.futures.ThreadPoolExecutor 的问题

查看 46|回复 0
作者:ohayoo   
各位大佬,python 的 concurrent.futures.ThreadPoolExecutor 下的 map 返回值是按提交顺序来的吗?
我之前一直以为用 map 的话 返回值是按提交的顺序来的,但今天看 map 对应的代码,注释是这样写的
Returns:
An iterator equivalent to: map(func, *iterables) but the calls may
be evaluated out-of-order.
这个意思是可能会乱序,并不能保证顺序返回吗?
如果 map 不能保证顺序返回, 但多线程的时候又希望按顺序返回,该怎么办呢?还望大佬们赐教
您需要登录后才可以回帖 登录 | 立即注册

返回顶部