New submission from Geoffrey Bache <[EMAIL PROTECTED]>: Run the following code on Windows:
import subprocess, os file = open("filename", "w") try: proc = subprocess.Popen("nosuchprogram", stdout=file) except OSError: file.close() os.remove("filename") This produces the following exception: Traceback (most recent call last): File "C:\processown.py", line 10, in <module> os.remove("filename") WindowsError: [Error 32] The process cannot access the file because it is being used by another process: 'filename' When the CreateProcess call fails the subprocess module should release the handles it provides. Unfortunately it seems to raise WindowsError before doing this. See also http://groups.google.com/group/comp.lang.python/browse_thread/thread/6157691ea3324779/6274e9f8bc8a71ee?hl=en#6274e9f8bc8a71ee As Tim Golden points out, this can be worked around by doing os.close(file.fileno()) at the end instead of file.close() ---------- components: Extension Modules messages: 68787 nosy: gjb1002 severity: normal status: open title: subprocess.Popen does not release process handles if process cannot be started type: behavior versions: Python 2.5 _______________________________________ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue3210> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com