[Python-checkins] cpython (merge 3.3 -> default): Merge concurrent.futures dict comp tweak from 3.3

nick.coghlan python-checkins at python.org
Tue Oct 16 15:14:49 CEST 2012


http://hg.python.org/cpython/rev/267d6d032652
changeset:   79754:267d6d032652
parent:      79752:cf39cb2b5009
parent:      79753:1280b38fe583
user:        Nick Coghlan <ncoghlan at gmail.com>
date:        Tue Oct 16 23:14:38 2012 +1000
summary:
  Merge concurrent.futures dict comp tweak from 3.3

files:
  Doc/library/concurrent.futures.rst |  8 +++-----
  1 files changed, 3 insertions(+), 5 deletions(-)


diff --git a/Doc/library/concurrent.futures.rst b/Doc/library/concurrent.futures.rst
--- a/Doc/library/concurrent.futures.rst
+++ b/Doc/library/concurrent.futures.rst
@@ -144,11 +144,9 @@
    # 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:

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list