Python creates "locked" temp dir
Christian Heimes
lists at cheimes.de
Wed Dec 8 13:23:57 EST 2010
Am 08.12.2010 19:05, schrieb astar:
> Hi,
>
> I recently got caught on tempfiles with respect to
> urllib.urlretrieve, which can create a tmpfile. Ah, but the file
> simply could not be found on the file system, even as root. But
> within the program that created the tmpfile, you could do useful
> things with the tmpfile. So the discussion in this thread is useful
> to me in understanding the rules. But having been given a clue by
> someone else, I never did find any python library documentation that
> was at all informative, even to the level of discourse in this
> thread.
By default the tempfile module creates anonymous temporary files. The
files are created with O_CREAT | O_EXCL and unlinked ASAP. As a result
the temporary file no longer has a filename on the file system, just an
open file descriptor in the current process. If you need a file with a
name, use the NamedTemporaryFile feature of the tempfile module.
Christian
More information about the Python-list
mailing list