Why do I get NameError: name 'as_completed' is not defined (I have from concurrent.futures import ThreadPoolExecutor)
Why do I get NameError: name 'as_completed' is not defined (I have from concurrent.futures import ThreadPoolExecutor)
我有以下代码:
从 concurrent.futures 导入 ThreadPoolExecutor
def load_database():
with ThreadPoolExecutor(max_workers=10) as executor:
futures = [executor.submit(load_person, x) for x in range(max_people - 1)]
for future in as_completed(futures):
return(future.result())
print(futures)
我收到“NameError:名称 'as_completed' 未定义”
我是否需要导入其他东西才能使用 as_completed?
谢谢,
克丽丝
as_completed
住在 concurrent.futures
所以你需要 from concurrent.futures import as_completed
我有以下代码:
从 concurrent.futures 导入 ThreadPoolExecutor
def load_database():
with ThreadPoolExecutor(max_workers=10) as executor:
futures = [executor.submit(load_person, x) for x in range(max_people - 1)]
for future in as_completed(futures):
return(future.result())
print(futures)
我收到“NameError:名称 'as_completed' 未定义”
我是否需要导入其他东西才能使用 as_completed?
谢谢, 克丽丝
as_completed
住在 concurrent.futures
所以你需要 from concurrent.futures import as_completed