pythonfuturesA futures implementation for Python | |
Download |
pythonfutures Ranking & Summary
Advertisement
- License:
- BSD License
- Price:
- FREE
- Publisher Name:
- Alex Gronholm
- Publisher web site:
- http://code.google.com/u/105081597892033910559/
pythonfutures Tags
pythonfutures Description
pythonfutures is a Java-style futures package for Python.This package is described in PEP-3148 and is included in Python 3.2.See the Python documentation for a full description.Example (Python 2.6)import futuresimport urllib2URLS = def load_url(url, timeout): return urllib2.urlopen(url, timeout=timeout).read()with futures.ThreadPoolExecutor(max_workers=5) as executor: 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 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()))Package DocumentationProduct's homepage
pythonfutures Related Software