Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5ecd004 commit d6d5cf3Copy full SHA for d6d5cf3
1 file changed
Doc/library/concurrent.futures.rst
@@ -144,11 +144,9 @@ ThreadPoolExecutor Example
144
# We can use a with statement to ensure threads are cleaned up promptly
145
with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor:
146
# Start the load operations and mark each future with its URL
147
- load_urls = [executor.submit(load_url, url, 60) for url in URLS]
148
- for future, url in zip(load_urls, URLS):
149
- future.url = url
150
- for future in concurrent.futures.as_completed(load_urls):
151
- 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]
152
try:
153
data = future.result()
154
except Exception as exc:
0 commit comments