os.remove OSError: [Errno 13] Permission denied

J

Joram Agten

Please put me in CC

When running the following program I get frequent errors like this one

Exception in thread Thread-4:
Traceback (most recent call last):
File "C:\Python24\lib\threading.py", line 442, in __bootstrap
self.run()
File "os.remove.py", line 25, in run
os.remove(filename)
OSError: [Errno 13] Permission denied:
'c:\\docume~1\\joag\\locals~1\\temp\\tmpx91tkx'

When leaving out the touch statement(line 24) in the loop of the class,
I do not get any errors.
This is on Windows XP SP2 with python-2.4.2 (you should have an exe
touch somewhere in you path for this to work)
Can somebody shed any light on this please?

Thanks in advance

Joram Agten
import os
import tempfile
import threading
import subprocess

def touch(filename):
output = str()
process = subprocess.Popen("touch " + filename ,
stdin=None,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
universal_newlines=True)
process.wait()

class this(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.start()

def run(self):
for i in range(0, 100):
filename = tempfile.mktemp()
f = open(filename, 'w')
f.write("test")
f.close()
touch(filename)
os.remove(filename)

getters = []
for i in range(0, 10):
getter = this()
getters.append(getter)

for getter in getters:
getter.join()

Visit Telindus Access Products at Cebit 2006, Hall 13, Booth 34, 9-15 March 2006.
Discover Telindus' range of access & surveillance products in a live "voice and video over DSL" demo and collect the new catalogue 2006-2007. See you in Hannover!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top