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 2011年07月04日 22:13 by vstinner, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| subprocess_check_output.patch | vstinner, 2011年07月04日 22:13 | review | ||
| subprocess_check_output-2.patch | vstinner, 2011年07月05日 11:02 | review | ||
| Messages (9) | |||
|---|---|---|---|
| msg139812 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2011年07月04日 22:13 | |
subprocess.check_output() doesn't close explicitly pipes if an error occurs. See for example issue #12493 for an example of an error on .communicate(). Attached patch uses a context manager to ensure that all pipes are always closed and that the status is read to avoid zombies. Other subprocess functions should be fixed: - call() (will fix check_call) - getstatusoutput() (will fix getoutput): see patch attached to the issue #10197 to replace os.popen() by subprocess.Popen |
|||
| msg139848 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2011年07月05日 11:02 | |
subprocess_check_output-2.patch is a more complete patch: "fix" (?) call(), check_output() and getstatusoutput(). These functions kill the process if an exception occurs to not hang on wait() in Popen.__exit__(). Because of the kill, I don't know if the fix should be applied to 2.7 and 3.2. In case of an exception, is it better to keep the subprocess alive, or to kill it? If we keep it alive, the caller of the function cannot interact with the process, and we don't know exactly when it will finish. By "exception", I mean unexpected exceptions: check_output() handles explicitly the TimeoutExpired exception. |
|||
| msg139903 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2011年07月05日 20:36 | |
See also issue #12044 which changed the context manager to call the wait() method. |
|||
| msg143297 - (view) | Author: Ross Lagerwall (rosslagerwall) (Python committer) | Date: 2011年09月01日 05:05 | |
The second patch looks good. Tests? I think it would be better to kill the process than to let it carry on. But, it *probably* shouldn't be applied to 2.7 & 3.2 given that it is a behaviour change. |
|||
| msg143312 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2011年09月01日 08:21 | |
> The second patch looks good. Tests? Ok, I will try to write a new patch with tests. > But, it *probably* shouldn't be applied to 2.7& 3.2 given that it is a behaviour change. I consider that this issue is a bug, so it should be fixed in 2.7 and 3.2. I agree that *killing* the process is a behaviour change, but we can just close pipes on error for 2.7 and 3.2. |
|||
| msg143313 - (view) | Author: Ross Lagerwall (rosslagerwall) (Python committer) | Date: 2011年09月01日 08:49 | |
> I consider that this issue is a bug, so it should be fixed in 2.7 and > 3.2. I agree that *killing* the process is a behaviour change, but we > can just close pipes on error for 2.7 and 3.2. Yeah, that seems right. |
|||
| msg143359 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2011年09月01日 21:54 | |
New changeset 86b7f14485c9 by Victor Stinner in branch 'default': Issue #12494: Close pipes and kill process on error in subprocess functions http://hg.python.org/cpython/rev/86b7f14485c9 |
|||
| msg143360 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2011年09月01日 21:57 | |
> The second patch looks good. Tests? I don't see how to test that the pipes are closed, because the Popen object (and its stdout and stderr attributes) are not visible outside the patched functions. > I consider that this issue is a bug, so it should be fixed in 2.7 > and 3.2. I tried to write a patch, but I chose to keep the code unchanged. I prefer to keep this little tricky bug, instead of introducing another more important regression. Reopen the issue if you have a script to test the fix, or if you really want a backport. |
|||
| msg262868 - (view) | Author: Martin Panter (martin.panter) * (Python committer) | Date: 2016年04月04日 20:51 | |
As I understand it, this change only made it to 3.3+ |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:19 | admin | set | github: 56703 |
| 2016年04月04日 20:51:44 | martin.panter | set | nosy:
+ martin.panter messages: + msg262868 versions: - Python 2.7, Python 3.2 |
| 2011年09月01日 21:57:18 | vstinner | set | status: open -> closed resolution: fixed messages: + msg143360 |
| 2011年09月01日 21:54:29 | python-dev | set | nosy:
+ python-dev messages: + msg143359 |
| 2011年09月01日 08:49:03 | rosslagerwall | set | messages: + msg143313 |
| 2011年09月01日 08:21:18 | vstinner | set | messages: + msg143312 |
| 2011年09月01日 05:05:51 | rosslagerwall | set | messages: + msg143297 |
| 2011年07月11日 12:06:46 | rosslagerwall | set | nosy:
+ rosslagerwall |
| 2011年07月05日 20:36:40 | vstinner | set | messages: + msg139903 |
| 2011年07月05日 11:02:45 | vstinner | set | files:
+ subprocess_check_output-2.patch messages: + msg139848 |
| 2011年07月04日 22:13:45 | vstinner | create | |