Possible bug in ThreadPoolExecutor, or just misinterpretation
INADA Naoki
songofacandy at gmail.com
Sun May 27 12:55:53 EDT 2018
On Mon, May 28, 2018 at 1:12 AM Santiago Basulto
<santiago.basulto at gmail.com>
wrote:
> 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?
Yes, you can use `future.as_completed()` instead.
> 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
> ?
I don't it's reasonable.
You can use multiprocessing.ThreadPool instead.
> Another option might be making `as_completed` work with map results too
> (which was my original intention).
I don't like this idea.
Regards,
--
INADA Naoki <songofacandy at gmail.com>
More information about the Python-list
mailing list