diff options
author | brian.quinlan <devnull@localhost> | 2010-02-24 09:01:30 +0000 |
---|---|---|
committer | brian.quinlan <devnull@localhost> | 2010-02-24 09:01:30 +0000 |
commit | 36bcb2a39438545db7c4b20d26ac67c462214e6e (patch) | |
tree | 4581938435d45b6ef10ec382781dae923c5d6b03 | |
parent | e69b63aebbdc8a53866e8acb1e94f983b4c37c14 (diff) | |
download | futures-36bcb2a39438545db7c4b20d26ac67c462214e6e.tar.gz |
Updated web crawl example to match new context manager behavior.
-rw-r--r-- | PEP.txt | 13 | ||||
-rw-r--r-- | docs/index.rst | 15 |
2 files changed, 15 insertions, 13 deletions
@@ -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 --------------------------- |