我在python 3.6中使用concurrent.futures
有这段代码:
with concurrent.futures.ProcessPoolExecutor(max_workers=MAX_WORKERS_ALLOWED) as executor:
for file in executor.map(self.upload_chunked_part, chunk_list):
total = total + file
elapsed_time = round(time.time() - start_time, 2)
current_speed = round(total / (elapsed_time * 1024 * 1024), 2)
progress_bar("Uploading %s at %sMB/s" %
(media.name, current_speed), total, size)
// Each loop returns "Login required to API"
self.upload_chunked_part
指的是与此代码所在的类关联的方法。当futures
调用该方法时,self
的实例将显示在被调用的对象中。如果我正常调用该方法,则代码与显示的代码不同:
self.upload_chunked_part(chunk) // Returns "Successful"
我希望我已经很好地解释了这个问题。关于如何进行这项工作的任何想法?