title: use concurrent futures with generator input
body: <p>I am downloading some information from webpages in the form</p>
  
  <pre><code>http://example.com?p=10
  http://example.com?p=20
  ...
  </code></pre>
  
  <p>The point is that I don't know how many they are. At some point I will receive an error from the server, or maybe at some point I want to stop the processing since I have enough. I want to run them in parallel.</p>
  
  <pre><code>def generator_query(step=10):
     i = 0
     yield "http://example.com?p=%d" % i
     i += step
  </code></pre>
  
  <pre><code>def task(url):
      t = request.get(url).text
      if not t:  # after the last one
         return None
      return t
  </code></pre>
  
  <p>I can implement it with consumer/producer pattern with queues, but I am wondering it is possible to have an higher level implementation, for example with the concurrent module.</p>
  
  <p>Non-concurrent example:</p>
  
  <pre><code>results = []
  for url in generator_query():
      results.append(task(url))
  </code></pre>