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!


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to