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.
| Author | gjb1002 |
|---|---|
| Recipients | gjb1002 |
| Date | 2008年06月26日.15:22:40 |
| SpamBayes Score | 3.8434493e-08 |
| Marked as misclassified | No |
| Message-id | <1214493762.8.0.246296591489.issue3210@psf.upfronthosting.co.za> |
| In-reply-to |
| Content | |
|---|---|
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() |
|
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2008年06月26日 15:22:43 | gjb1002 | set | spambayes_score: 3.84345e-08 -> 3.8434493e-08 recipients: + gjb1002 |
| 2008年06月26日 15:22:42 | gjb1002 | set | spambayes_score: 3.84345e-08 -> 3.84345e-08 messageid: <1214493762.8.0.246296591489.issue3210@psf.upfronthosting.co.za> |
| 2008年06月26日 15:22:41 | gjb1002 | link | issue3210 messages |
| 2008年06月26日 15:22:40 | gjb1002 | create | |