Windows process ownership trouble

geoffbache geoff.bache at
Wed Jun 25 14:01:14 CEST 2008

Am currently being very confused over the following code on Windows

import subprocess, os

file = open("filename", "w")
    proc = subprocess.Popen("nosuchprogram", stdout=file)
except OSError:

This produces the following exception:

Traceback (most recent call last):
  File "C:\", line 10, in <module>
WindowsError: [Error 32] The process cannot access the file because it
is being used by another process: 'filename'

How can it be in use by another process? The process didn't even
start, right?

Would appreciate some help: is this a Python bug, or a Windows bug, or
just me being confused...?

More information about the Python-list mailing list