Windows process ownership trouble

geoffbache geoff.bache at jeppesen.com
Fri Jun 27 02:50:46 EDT 2008


Tim,

I copied your code exactly from my browser and ran it, so I don't
think there was a typo.
I could upgrade to Python 2.5.2 I suppose to compare and contrast, but
I need to support older
Python versions anyway so it's a bit academic...

Your speculation about garbage collection did set me going, however,
and I discovered
that the following code does work on my system, so now I have a
functional workaround:

import os
import subprocess

def runProcess():
   f = open ("filename", "w")
   try:
      proc = subprocess.Popen ("blah", stdout=f)
   except OSError:
      f.close ()

runProcess()
os.remove ("filename")

So it seems that some things are only being garbage collected when the
function exits, but not when the
except clause exits or when the exception is thrown.

Geoff



More information about the Python-list mailing list