summaryrefslogtreecommitdiffstats
path: root/Doc/library/concurrent.futures.rst
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2012-10-16 13:14:03 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2012-10-16 13:14:03 (GMT)
commitd6d5cf33ef7ad248a0baa2568f2a15a265a73734 (patch)
tree2d4a7535da5b4d4e905b4380ce1fdb51e5122b58 /Doc/library/concurrent.futures.rst
parent5ecd00402eec2fc3238f4db6a30b25843956c179 (diff)
downloadcpython-d6d5cf33ef7ad248a0baa2568f2a15a265a73734.zip
cpython-d6d5cf33ef7ad248a0baa2568f2a15a265a73734.tar.gz
cpython-d6d5cf33ef7ad248a0baa2568f2a15a265a73734.tar.bz2
A dict comprehension is much prettier (thanks Antoine)
Diffstat (limited to 'Doc/library/concurrent.futures.rst')
-rw-r--r--Doc/library/concurrent.futures.rst8
1 files changed, 3 insertions, 5 deletions
diff --git a/Doc/library/concurrent.futures.rst b/Doc/library/concurrent.futures.rst
index 70b0fd1..62d8eac 100644
--- a/Doc/library/concurrent.futures.rst
+++ b/Doc/library/concurrent.futures.rst
@@ -144,11 +144,9 @@ ThreadPoolExecutor Example
# We can use a with statement to ensure threads are cleaned up promptly
with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor:
# Start the load operations and mark each future with its URL
- load_urls = [executor.submit(load_url, url, 60) for url in URLS]
- for future, url in zip(load_urls, URLS):
- future.url = url
- for future in concurrent.futures.as_completed(load_urls):
- url = future.url
+ future_to_url = {executor.submit(load_url, url, 60):url for url in URLS}
+ for future in concurrent.futures.as_completed(future_to_url):
+ url = future_to_url[url]
try:
data = future.result()
except Exception as exc: