Possible bug in ThreadPoolExecutor, or just misinterpretation

Santiago Basulto santiago.basulto at gmail.com
Sun May 27 12:00:12 EDT 2018


Hey list! I might have encountered a "bug", or maybe it's just a "design
decision" :)

Here's some example code:
https://gist.github.com/santiagobasulto/3513a50ec0dc939e8f7bb2ecfa8d4ae2

The problem is `ThreadPoolExecutor.map()`. It's not returning tasks "as
completed" but sequentially.  I understand that might be the desired
behavior since the function is `map()` and you *might* be expecting the
results "in order".

So, the questions are: Is this expected behavior? Is there any chance to
add an `map_unordered` as multiprocessing has
<https://docs.python.org/3/library/multiprocessing.html#multiprocessing.pool.Pool.imap_unordered>?
Another option might be making `as_completed` work with map results too
(which was my original intention).

Thanks for your answers in advance!

-- 
Santiago Basulto.-
Up!



More information about the Python-list mailing list