-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
executor.map hangs at seemly random iteration when iterable is large #114948
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Is this reproducible without |
Yes, same behavior when using |
Win10, main, Command Prompt, with
With the needed (on Windows) clause added, it prints 0 to 12 on separate lines and hangs. ^C and I get 12 interlaced tracebacks with some of the following lines
|
Thanks all for the discussion and feedback. I've started a PR which should hopefully address/help with this and a couple of related issues. |
This does not hang infinitely, it just takes a long time. (~1min on my comupter). This is the main process timeline for a "normal" The MainThread is doing the
During the first call of It will get the When the task queue is full, the manager waits for a broken or wakeup signal in In this function, it needs to read all the pending Each So if you have 1e6 tasks like in the example, you'll need 50s to process all the wake up signals before you can send out more So it's not a real dead lock, it just takes a long time. However, I do agree that if we can do something about it, that would be nice. But it won't make this go any faster even with lazy evaluation - it will make this smoother, as each wakeup signal always need to take 50us and it needs to be processed anyway (but it can be parallelized so if the task itself takes more than that, it should be ignorable if it's not blocking the task distribution). |
@gaogaotiantian Thanks for the profiling, please see #114975 for an attempt to improve the large iterator use case |
Ah okay this is a false alarm. What you should do is to specify a The docs says:
executor.map(print, np.arange(1000000), chunksize=10000) should just solve the issue. |
Bug report
Bug description:
Minimum working example of issue:
Each time this is run it seems to hang at a different iteration with no apparent CPU or memory usage. May be related to #74028
CPython versions tested on:
3.9
Operating systems tested on:
Linux
Linked PRs
The text was updated successfully, but these errors were encountered: