<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On 6 Mar 2010, at 07:38, Brett Cannon wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">The PEP says that futures.wait() should only use keyword arguments past its first positional argument, but the PEP has the function signature as ``wait(fs, timeout=None, return_when=ALL_COMPLETED)``. Should it be ``wait(fs, *, timeout=None, return_when=ALL_COMPLETED)``?<br></blockquote><div><br></div>Hi Brett,</div><div><br></div><div>That recommendation was designed to make it easy to change the API without breaking code.</div><div><br></div><div>I'd don't think that recommendation makes sense anymore any I'll update the PEP.</div><div><br></div><div>Cheers,</div><div>Brian<br><br><blockquote type="cite"><div class="gmail_quote">On Thu, Mar 4, 2010 at 22:03, Brian Quinlan <span dir="ltr"><<a href="mailto:brian@sweetapp.com">brian@sweetapp.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"> Hi all,<br> <br> I recently submitted a daft PEP for a package designed to make it easier to execute Python functions asynchronously using threads and processes. It lets the user focus on their computational problem without having to build explicit thread/process pools and work queues.<br> <br> The package has been discussed on stdlib-sig but now I'd like this group's feedback.<br> <br> The PEP lives here:<br> <a href="http://python.org/dev/peps/pep-3148/" target="_blank">http://python.org/dev/peps/pep-3148/</a><br> <br> Here are two examples to whet your appetites:<br> <br> """Determine if several numbers are prime."""<br> import futures<br> import math<br> <br> PRIMES = [<br> 112272535095293,<br> 112582705942171,<br> 112272535095293,<br> 115280095190773,<br> 115797848077099,<br> 1099726899285419]<br> <br> def is_prime(n):<br> if n % 2 == 0:<br> return False<br> <br> sqrt_n = int(math.floor(math.sqrt(n)))<br> for i in range(3, sqrt_n + 1, 2):<br> if n % i == 0:<br> return False<br> return True<br> <br> # Uses as many CPUs as your machine has.<br> with futures.ProcessPoolExecutor() as executor:<br> for number, is_prime in zip(PRIMES, executor.map(is_prime, PRIMES)):<br> print('%d is prime: %s' % (number, is_prime))<br> <br> <br> """Print out the size of the home pages of various new sites (and Fox News)."""<br> import futures<br> import urllib.request<br> <br> URLS = ['<a href="http://www.foxnews.com/" target="_blank">http://www.foxnews.com/</a>',<br> '<a href="http://www.cnn.com/" target="_blank">http://www.cnn.com/</a>',<br> '<a href="http://europe.wsj.com/" target="_blank">http://europe.wsj.com/</a>',<br> '<a href="http://www.bbc.co.uk/" target="_blank">http://www.bbc.co.uk/</a>',<br> '<a href="http://some-made-up-domain.com/" target="_blank">http://some-made-up-domain.com/</a>']<br> <br> def load_url(url, timeout):<br> return urllib.request.urlopen(url, timeout=timeout).read()<br> <br> with futures.ThreadPoolExecutor(max_workers=5) as executor:<br> # Create a future for each URL load.<br> future_to_url = dict((executor.submit(load_url, url, 60), url)<br> for url in URLS)<br> <br> # Iterate over the futures in the order that they complete.<br> for future in futures.as_completed(future_to_url):<br> url = future_to_url[future]<br> if future.exception() is not None:<br> print('%r generated an exception: %s' % (url,<br> future.exception()))<br> else:<br> print('%r page is %d bytes' % (url, len(future.result())))<br> <br> Cheers,<br> Brian<br> _______________________________________________<br> Python-Dev mailing list<br> <a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br> <a href="http://mail.python.org/mailman/listinfo/python-dev" target="_blank">http://mail.python.org/mailman/listinfo/python-dev</a><br> Unsubscribe: <a href="http://mail.python.org/mailman/options/python-dev/brett%40python.org" target="_blank">http://mail.python.org/mailman/options/python-dev/brett%40python.org</a><br> </blockquote></div><br></blockquote></div><br></body></html>