Форум сайта python.su
есть такой код:
with futures.ThreadPoolExecutor(max_workers=max_threads) as executor:
future_to_url = {}
processId = 0
for link in links:
ft = executor.submit(worker, (processId, link, attr))
ft.add_done_callback(self.parent.threads.process_result)
future_to_url.update({ft:link})
processId += 1
for future in futures.as_completed(future_to_url, timeout=timeout):
url = future_to_url[future]
if future.exception() is not None:
print ('%r generated an exception: %s' % (url,
future.exception()))
else:
print ('result', future.result())
self.executor = ThreadPoolExecutor(max_workers=mt_cnf)
for i, job in enumerate(jobs):
future = self.executor.submit(self.worker, [i, job, attr])
future.add_done_callback(self.process_result)
self.pending.add(future)
for future in futures.as_completed(future_to_url, timeout=timeout):
Отредактировано (Март 31, 2011 22:30:41)
Офлайн