Is tempfile.mkdtemp() thread-safe?

Gabriel Rossetti gabriel.rossetti at arimaz.com
Thu Aug 21 07:22:33 EDT 2008


Hello,

I'm using tempfile.mkdtemp() in a multithreading program and I've been 
having problems with it. Sometimes it tells me the file I'm trying to 
access (in the directory created with tempfile.mkdtemp()) doesn't exist. 
I suspect that tempfile.mkdtemp() returns the same directory to 
different threads sometimes. Does anyone know anything about this or 
have a solution? I have to create unique and temp. directories to use an 
external program that creates a temp. file with the same name every 
time, thus if I want to call it from several threads, each call has to 
be from a different directory.

Thank you,
Gabriel



More information about the Python-list mailing list