summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrian.quinlan <devnull@localhost>2010-02-24 09:01:30 +0000
committerbrian.quinlan <devnull@localhost>2010-02-24 09:01:30 +0000
commit36bcb2a39438545db7c4b20d26ac67c462214e6e (patch)
tree4581938435d45b6ef10ec382781dae923c5d6b03
parente69b63aebbdc8a53866e8acb1e94f983b4c37c14 (diff)
downloadfutures-36bcb2a39438545db7c4b20d26ac67c462214e6e.tar.gz
Updated web crawl example to match new context manager behavior.
-rw-r--r--PEP.txt13
-rw-r--r--docs/index.rst15
2 files changed, 15 insertions, 13 deletions
diff --git a/PEP.txt b/PEP.txt
index 5048405..d2e2175 100644
--- a/PEP.txt
+++ b/PEP.txt
@@ -84,12 +84,13 @@ Web Crawl Example
future_to_url = dict((executor.submit(load_url, url, 60), url)
for url in URLS)
- for future in futures.as_completed(future_to_url):
- url = future_to_url[future]
- if future.exception() is not None:
- print('%r generated an exception: %s' % (url, future.exception()))
- else:
- print('%r page is %d bytes' % (url, len(future.result())))
+ for future in futures.as_completed(future_to_url):
+ url = future_to_url[future]
+ if future.exception() is not None:
+ print('%r generated an exception: %s' % (url,
+ future.exception()))
+ else:
+ print('%r page is %d bytes' % (url, len(future.result())))
Interface
---------
diff --git a/docs/index.rst b/docs/index.rst
index 356c059..4b1a7aa 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -81,8 +81,8 @@ ThreadPoolExecutor Example
^^^^^^^^^^^^^^^^^^^^^^^^^^
::
- import urllib.request
import futures
+ import urllib.request
URLS = ['http://www.foxnews.com/',
'http://www.cnn.com/',
@@ -97,12 +97,13 @@ ThreadPoolExecutor Example
future_to_url = dict((executor.submit(load_url, url, 60), url)
for url in URLS)
- for future in futures.as_completed(future_to_url):
- url = future_to_url[future]
- if future.exception() is not None:
- print('%r generated an exception: %s' % (url, future.exception()))
- else:
- print('%r page is %d bytes' % (url, len(future.result())))
+ for future in futures.as_completed(future_to_url):
+ url = future_to_url[future]
+ if future.exception() is not None:
+ print('%r generated an exception: %s' % (url,
+ future.exception()))
+ else:
+ print('%r page is %d bytes' % (url, len(future.result())))
ProcessPoolExecutor Objects
---------------------------