uniqueness of temporary files generated by tempfile

  • Thread starter Catherine Moroney
  • Start date
C

Catherine Moroney

Are the temporary filenames generated by the tempfile module
guaranteed to be unique?

I have a need to generate temporary files within an application,
and I will have many instances of this application running as a
sub-process (so I can submit them to a batch queue). Is there
any danger of my different sub-processes accidentally generating
the same filename, or does tempfile check for the existence of
a similarly-named file before generating a filename?

What's the recommended way of generating temporary filenames
that are guaranteed to be unique even with multiple processes
running simultaneously?

Catherine
 
E

Emile van Sebille

Catherine said:
Are the temporary filenames generated by the tempfile module
guaranteed to be unique?

I suspect this answers your question...

Emile

Help on module tempfile:

NAME
tempfile - Temporary files.

FILE
c:\python25\lib\tempfile.py

DESCRIPTION
This module provides generic, low- and high-level interfaces for
creating temporary files and directories. The interfaces listed
as "safe" just below can be used without fear of race conditions.
Those listed as "unsafe" cannot, and are provided for backward
compatibility only.
 

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,968
Messages
2,570,152
Members
46,697
Latest member
AugustNabo

Latest Threads

Top