-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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
multiprocessing.Pool map hangs #122930
Comments
I haven't had a chance to try and reproduce this yet, but does this occur on 3.12+? Things on <3.12 can only get security fixes. |
Thanks for your reply. Is the lack of close() and join() in my code the reason why this is happening?
Sorry, about3.12+,I don't have the opportunity to test it. |
Any version below 3.12 cannot get bugfixes like this anymore, they can only be changed for a security problem (which doesn't include this issue, unfortunately). FWIW, I wasn't able to reproduce the issue on 3.12 |
Yes, probably. The docs say in https://docs.python.org/3/library/multiprocessing.html#multiprocessing.pool.Pool:
The best practice is to use a context manager as in the first docs example: from multiprocessing import Pool
def f(x):
return x*x
if __name__ == '__main__':
with Pool(5) as p:
print(p.map(f, [1, 2, 3])) I also cannot reproduce the hanging, even on 3.10 but since the usage of Pool is incorrect, I am closing this one as |
@ZeroIntensity @picnixz In fact, in my environment(3.10), the probability of this problem reproduce is also very low. |
Bug report
Bug description:
Q:
Run the following code, sometimes subprogres that is created by [class A's Pool or class B's Pool] is going to sleeping status, and there is not any error log output.
But code(#3 or #4)run success, code(#1 or #2) is not run,The reason is pool.close() and pool.join() is not writed in source code?
CPython versions tested on:
3.10
Operating systems tested on:
Linux
The text was updated successfully, but these errors were encountered: