Cannot use concurrent.futures.ThreadPoolExecutor() within a loop

Cannot use concurrent.futures.ThreadPoolExecutor() within a for loop, it dosent work after first iteration.

Please don’t post images of text.

Please include a traceback, just saying “it does not work” makes it hard to help you.

Your code breaks after the first loop because your args is a generator object. Generators can be iterated over only once, after that they are exhausted. Try making args a list instead, by replacing the outermost parentheses in the comprehension with brackets.

1 Like