你是对的,你只需要提供一个额外的参数
self
。但你一点都没给。所以你还差一个。拆分提交以使其视觉清晰:
my_d = dict( # Making a dict
# With key as result object from invoking `mt_main` with no additional arguments
(executor.submit(g_f_p_f.mt_main),
# And value j
j)
for j in range(i,297085))
也许你是想过去
j
作为论点?假设它也应该是该值,则为:
# Note second argument to submit, which becomes only non-self argument to mt_main
my_d = dict((executor.submit(g_f_p_f.mt_main, j),j) for j in range(i,297085))
或者简化一针一线,因为
concurrent.futures
应该意味着你可以使用
dict
comprehensions
(这也将
submit
从其价值调用
:
为了更好的视觉解析):
my_d = {executor.submit(g_f_p_f.mt_main, j): j for j in range(i, 297085)}