[issue3210] subprocess.Popen does not release process handles if process cannot be started
Hirokazu Yamamoto
report at bugs.python.org
Fri Oct 9 14:14:06 CEST 2009
Hirokazu Yamamoto <ocean-city at m2.ccsnet.ne.jp> added the comment:
No, this is not duplicate of issue5179. That issue described handle was
leaked when exception occurred. But this issue is not *leak*. See
following code.
import subprocess, os, sys
file = open("filename", "w")
try:
proc = subprocess.Popen("nosuchprogram", stdout=file)
except OSError:
file.close()
sys.exc_clear() # here we go....
os.remove("filename") # now we can delete file!
subprocess is implemented using sp_handle_type in PC/_subprocess.c
(windows). This object is in exception stack frame(?), so handle lives
until another exception occurs or explicitly sys.exc_clear() is called.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3210>
_______________________________________
More information about the Python-bugs-list
mailing list