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 2012年03月11日 16:02 by dabrahams, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| winspterminate.patch | pitrou, 2012年03月11日 16:42 | review | ||
| Messages (8) | |||
|---|---|---|---|
| msg155391 - (view) | Author: Dave Abrahams (dabrahams) | Date: 2012年03月11日 16:02 | |
Try the following script on posix and Windows. On Posix: launched . . . exiting killed on Windows: launched . . . exiting Traceback (most recent call last): File "sp.py", line 16, in <module> p.terminate() File "c:\Python26\lib\subprocess.py", line 949, in terminate _subprocess.TerminateProcess(self._handle, 1) WindowsError: [Error 5] Access is denied This inconsistency seems unnecessary and is an obstacle to writing portable code. from subprocess import * import sys, time p = Popen([sys.executable, '-c', ''' import time, sys for i in range(3): time.sleep(.3) print '.', sys.stdout.flush() print 'exiting' '''], stdout = sys.stdout, stderr = sys.stderr) print 'launched' time.sleep(2) p.terminate() print 'killed' |
|||
| msg155392 - (view) | Author: Dave Abrahams (dabrahams) | Date: 2012年03月11日 16:08 | |
By the way, the suggested fix would be for terminate() to return a value indicating if the process were already terminated, and not throw an exception in that case. For a user to handle the issue correctly on Windows is rather a nasty project involving a race between process death and the call to terminate() |
|||
| msg155394 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2012年03月11日 16:42 | |
Here is a patch for 3.3. I'm not sure it should be backported, as it's a slight change in behaviour. |
|||
| msg155396 - (view) | Author: Gregory P. Smith (gregory.p.smith) * (Python committer) | Date: 2012年03月11日 17:11 | |
Raising an exception on terminate is a bug. I'd backport this to 2.7 and 3.2. I don't actually have Windows to test on so i'll leave committing that to people who do. |
|||
| msg155399 - (view) | Author: Martin v. Löwis (loewis) * (Python committer) | Date: 2012年03月11日 18:11 | |
+1 for backporting to the bug fix releases. |
|||
| msg155404 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2012年03月11日 18:37 | |
New changeset 41b1fe5a75a6 by Antoine Pitrou in branch '3.2': Issue #14252: Fix subprocess.Popen.terminate() to not raise an error under Windows when the child process has already exited. http://hg.python.org/cpython/rev/41b1fe5a75a6 New changeset f452d7d5470d by Antoine Pitrou in branch 'default': Issue #14252: Fix subprocess.Popen.terminate() to not raise an error under Windows when the child process has already exited. http://hg.python.org/cpython/rev/f452d7d5470d |
|||
| msg155405 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2012年03月11日 18:45 | |
New changeset b6ec3b717f7e by Antoine Pitrou in branch '2.7': Issue #14252: Fix subprocess.Popen.terminate() to not raise an error under Windows when the child process has already exited. http://hg.python.org/cpython/rev/b6ec3b717f7e |
|||
| msg155406 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2012年03月11日 18:45 | |
Ok, I've then fixed the bug in all 3 branches. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:27 | admin | set | github: 58460 |
| 2012年03月11日 18:45:47 | pitrou | set | status: open -> closed resolution: fixed messages: + msg155406 stage: patch review -> resolved |
| 2012年03月11日 18:45:19 | python-dev | set | messages: + msg155405 |
| 2012年03月11日 18:37:53 | python-dev | set | nosy:
+ python-dev messages: + msg155404 |
| 2012年03月11日 18:11:18 | loewis | set | nosy:
+ loewis messages: + msg155399 versions: + Python 2.7, Python 3.2 |
| 2012年03月11日 17:11:44 | gregory.p.smith | set | messages: + msg155396 |
| 2012年03月11日 16:42:07 | pitrou | set | files:
+ winspterminate.patch versions: + Python 3.3, - Python 2.6 keywords: + patch nosy: + gregory.p.smith, tim.golden, brian.curtin, pitrou messages: + msg155394 stage: patch review |
| 2012年03月11日 16:08:04 | dabrahams | set | messages: + msg155392 |
| 2012年03月11日 16:02:48 | dabrahams | create | |