title: Python 3 concurrent.futures - process for loop in parallel
body: <p>If I have understood correctly how the <code>concurrent.futures</code> module in Python 3 works, the following code:</p>
  
  <pre><code>import concurrent.futures
  import threading
  
  # Simple function returning a value
  def test(i):
  
      a = 'Hello World\n'
      return a
  
  
  def main():
      output1 = list()
  
      with concurrent.futures.ThreadPoolExecutor() as executor:
  
          # psdd iterator to test function
          for out1 in executor.map(test, range(0, 10)):
              # append returned result
              output1.append(out1)
  
              # confirm output
              print(output1)
              print("Task Executed {}".format(threading.current_thread()))
  
  
  if __name__ == '__main__':
      main()
  </code></pre>
  
  <p>...performs the following functions:</p>
  
  <ol>
  <li>Passes a for loop to the function called <code>test()</code>.</li>
  <li>Processes the loop in parallel, rather than in serial.</li>
  </ol>
  
  <p>However, what I really want is to process the loop in parallel in my <code>main()</code> function as so:</p>
  
  <pre><code>import concurrent.futures
  import threading
  
  
  def main():
      output1 = list()
  
      with concurrent.futures.ThreadPoolExecutor() as executor:
  
          # psdd iterator to test function
          for out1 in executor.submit(range(0, 10)):
  
              a = 'Hello World\n'
              # append returned result
              output1.append(a)
  
              # confirm output
              print(output1)
              print("Task Executed {}".format(threading.current_thread()))
  
  
  if __name__ == '__main__':
      main()
  </code></pre>
  
  <p>...this however produces the following error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "G:\HTPC Scripts\WebGrab Plus\TESTTESTTEST2.py", line 221, in &lt;module&gt;
      main()
    File "G:\HTPC Scripts\WebGrab Plus\TESTTESTTEST2.py", line 209, in main
      for out1 in executor.submit(range(0, 10)):
  TypeError: 'Future' object is not iterable
  </code></pre>
  
  <p>What do I need to amend in my code?</p>
  
  <p>Thanks</p>