Unable to remove file

Hi,
In this script I’m trying to pump some rib data to Aqsis:

os.chdir("C:/Documents and Settings/owndir/Mijn documenten/software/Aqsis 0.9.3/Aqsis/bin")
infile = tempfile.mkstemp()
c = file(infile[1], "w")
c.write(rib)
c.close()
a = os.spawnv(os.P_NOWAIT, 'aqsis', ['aqsis', infile[1]])
os.unlink(infile[1])

The file renders fine, but I can’t remove the file afterwards. It returns this error:

Traceback (most recent call last):
File “ribexporter_testmenu.”, line 75, in button_event
File “ribexporter_testmenu.”, line 55, in stream_rib
OSError: [Errno 13] Permission denied: ‘c:\docume~1\owndir\locals~1\ emp\ mpq
jxig9’

I don’t think Aqsis is still using the file when I’m trying to remove it, because the “Python script error: check console” only pops up when the image is finished rendering. After I close Aqsis’ framebuffer I still can’t remove the file in Windows Explorer. I can only remove the tempfile if I close Blender. If the script and Aqsis are finished but Blender is still open and I try to remove it in Windows Explorer, I get an error like: “Can’t remove file, it still might be in use by a program.”
The same problem occurs when I open Aqsis with system() instead of spawnv(). Blender seems to occupy the tempfile… :expressionless:

Windows XP Home
Blender 2.36 Intel optimized
Python 2.3.3

I tried to run a simplified version of the script from the Python IDLE too, and the exact same thing happened.

  • Rendering goes fine
  • When rendering is finished an error pops up, saying it (or I) doesn’t have permission to remove the tempfile
  • The tempfile still is there in my temp directory.
  • I can’t remove it manually either, Windows Explorer and CMD (the Windows DOS console or whatever it’s called) say a program still uses it
  • The tempfile can only be removed when I close the IDLE (or Blender)

So I guess it doesn’t have anything do with Blender…
Please help! :frowning: