Windows process ownership trouble

geoffbache geoff.bache at jeppesen.com
Thu Jun 26 17:25:40 CEST 2008


Thanks Tim, very helpful again.

I've now reported this as http://bugs.python.org/issue3210
and implemented your suggested workaround.

Regards,
Geoff

On Jun 25, 9:19 pm, Tim Golden <m... at timgolden.me.uk> wrote:
> geoffbache wrote:
> > Am currently being very confused over 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")
>
> Forgot to say: slightly awkward, but you can work around
> it like this:
>
> <code>
> import os
> import subprocess
>
> f = open ("filename", "w")
> try:
>    proc = subprocess.Popen ("blah", stdout=f)
> except OSError:
>    os.close (f.fileno ())
>
> os.remove ("filename")
>
> </code>
>
> TJG




More information about the Python-list mailing list