0
我有以下代碼:地圖不返回任何東西
def upload_to_s3(filepath, unique_id):
# do something
print s3_url # <-- Confirming that this `s3_url` variable is not None
return s3_url
threads = []
for num, list_of_paths in enumerate(chunked_paths_as_list):
for filepath in list_of_paths:
t = threading.Thread(target=upload_to_s3, args=(filepath, self.unique_id))
t.start()
threads.append(t)
results = map(lambda t: t.join(), threads)
print results
不幸的是,這是每一個項目返回None
:
[None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None]
>>>>> TIME: 13.9884989262
什麼我需要做的就是在該return
聲明以上map
?
謝謝,這是有道理的。你能告訴我如何在上面的例子中使用'Queue'對象嗎? – David542 2014-09-22 20:08:38
另請參閱http://stackoverflow.com/a/6894023/416467另一種方法。 – kindall 2014-09-22 21:15:17