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 maxtasksperchild results in hang #54541
Comments
v.3.2a3 If the maxtasksperchild argument is used, the program will just hang after whatever that value is rather than working as expected. Tested in Windows XP 32-bit test code: import multiprocessing
def f(x):
return 0;
if __name__ == '__main__':
pool = multiprocessing.Pool(processes=2,maxtasksperchild=1);
results = list();
for i in range(10):
results.append(pool.apply_async(f, (i)));
pool.close();
pool.join();
for r in results:
print(r);
print("Done"); |
I can duplicate this using python-2.7-8.fc14.1 on Fedora 14, and using map_async with the pool. |
This problem arises because the pool's close method is called before all the tasks have completed. Putting a sleep(1) before pool.close() won't exhibit this lockup. Note: I noticed that there are some thread-unsafe operations (the cache that can be modified from different threads, and thread states are modified also from different threads). While this isn't an issue with the current cPython implementation (GIL), I wonder if this should be fixed. |
Yes. We should fix those. |
Here's an updated patch. |
The patch looks good to me, thanks. |
New changeset 3465a9b2d25c by Charles-François Natali in branch '2.7': New changeset 52c98a729a71 by Charles-François Natali in branch '3.2': New changeset c2cdabc44665 by Charles-François Natali in branch 'default': |
James, thanks for the report! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: