This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2015年08月24日 17:05 by Jonas Obrist, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| pool_segfault.py | Jonas Obrist, 2015年08月24日 18:00 | Program showing how a segfaulting Pool.apply will hang forever | ||
| process_segfault.py | Jonas Obrist, 2015年08月24日 18:00 | Program showing that Process will run as expected if target segfaults | ||
| patch.diff | Jonas Obrist, 2015年08月25日 18:22 | patch that adds a warning if a worker exits prematurely | review | |
| Messages (4) | |||
|---|---|---|---|
| msg249068 - (view) | Author: Jonas Obrist (Jonas Obrist) * | Date: 2015年08月24日 17:05 | |
When using multiprocessing.Pool, if the function run in the pool segfaults, the program will simply hang forever. However when using multiprocessing.Process directly, it runs fine, setting the exitcode to -11 as expected. I would expect the Pool to behave similar to Process, or at the very least an exception to be raised instead of just silently hanging forever. I was able to reproduce this issue both on Linux (Ubuntu 15.04) and Mac OS X. |
|||
| msg249077 - (view) | Author: Jonas Obrist (Jonas Obrist) * | Date: 2015年08月24日 21:56 | |
So the reason this is happening is very simple: When using Pool.apply, the task (function) is sent to the task queue, which is consumed by the worker. At this point the task is "in progress". However, the worker dies without being able to finish the task or in any other way tell the Pool that it can't finish the task. The actual process is then ended by the Pool but the task is still in limbo, so any attempt at getting a result will hang forever. I'm not sure there's a straight forward way to solve this (the ways I can think of from the top of my head involve adding quite a bit of overhead to the Pool so it keeps track of which process/worker is handling which task at a given time, so if it exits prematurely this task can be finished), but at the very least this case should be documented I think. |
|||
| msg249147 - (view) | Author: Jonas Obrist (Jonas Obrist) * | Date: 2015年08月25日 18:22 | |
I've added a patch that would simply warn the user if a worker exits prematurely. |
|||
| msg250474 - (view) | Author: Brian Boonstra (brianboonstra) | Date: 2015年09月11日 13:58 | |
See also issue 22393 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:20 | admin | set | github: 69115 |
| 2015年09月16日 17:01:10 | berker.peksag | set | superseder: multiprocessing.Pool shouldn't hang forever if a worker process dies unexpectedly stage: resolved |
| 2015年09月16日 11:47:34 | Jonas Obrist | set | status: open -> closed resolution: duplicate |
| 2015年09月11日 13:58:47 | brianboonstra | set | nosy:
+ brianboonstra messages: + msg250474 |
| 2015年08月25日 18:22:37 | Jonas Obrist | set | files:
+ patch.diff keywords: + patch messages: + msg249147 |
| 2015年08月24日 21:56:57 | Jonas Obrist | set | messages: + msg249077 |
| 2015年08月24日 18:00:55 | Jonas Obrist | set | files: + process_segfault.py |
| 2015年08月24日 18:00:30 | Jonas Obrist | set | files: + pool_segfault.py |
| 2015年08月24日 18:00:09 | Jonas Obrist | set | files: - process_segfault.py |
| 2015年08月24日 18:00:06 | Jonas Obrist | set | files: - pool_segfault.py |
| 2015年08月24日 18:00:01 | Jonas Obrist | set | files: - setup.py |
| 2015年08月24日 17:59:57 | Jonas Obrist | set | files: - segfault.c |
| 2015年08月24日 17:06:39 | Jonas Obrist | set | files: + process_segfault.py |
| 2015年08月24日 17:06:22 | Jonas Obrist | set | files: + setup.py |
| 2015年08月24日 17:05:56 | Jonas Obrist | set | files: + segfault.c |
| 2015年08月24日 17:05:17 | Jonas Obrist | create | |