title: How do i use ThreadPoolExecutor submit with a function that yields in Python?
body: <p>I have the following code.</p>
  <pre><code>def foos(n):
      sleep(0.5)
      yield n
  
  k = 8
  futures = []
  with ThreadPoolExecutor(10) as exc:
      for i in range(k):
          futures.append(exc.submit(foos, i))
      for future in as_completed(futures):
          result = future.result()
          for v in result:
              print(v)
  </code></pre>
  <p>This code currently prints sequentially with an interval of 0.5 secs. How do i concurrently pull the results?</p>