[ python-Bugs-857566 ] tempfile.mktemp() omits pid from name

SourceForge.net noreply at sourceforge.net
Sat Jun 25 22:21:01 CEST 2005


Bugs item #857566, was opened at 2003-12-10 14:53
Message generated for change (Comment added) made by birkenfeld
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=857566&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.3
>Status: Closed
>Resolution: Wont Fix
Priority: 5
Submitted By: Gottfried Ganßauge (ganssauge)
Assigned to: Nobody/Anonymous (nobody)
Summary: tempfile.mktemp() omits pid from name

Initial Comment:
In python2.2 names created using tempfile.mktemp() 
contained the current pid as a prefix.
This behaviour has changed and now processes running 
concurrently are prone to races.
1.) In my application which forks a few thousand sub 
processes over time sometimes tempfiles created by one 
subprocess are deleted by another.
2.) Also this probably leads to longer creation times 
when two processes want to create a temp file at the 
same time on multiprocessor machines because both 
processes are using the same rng with the same seed to 
generate names.
Sorry, no code here, because 1. happens only a few 
times when running with huge amounts of data and 
because 2. is only a speculation.

I would propose to reinstate the former behaviour.

----------------------------------------------------------------------

>Comment By: Reinhold Birkenfeld (birkenfeld)
Date: 2005-06-25 22:21

Message:
Logged In: YES 
user_id=1188172

Closing this as Won't Fix, as mktemp is really deprecated
now and shouldn't be used.

----------------------------------------------------------------------

Comment By: Gottfried Ganßauge (ganssauge)
Date: 2003-12-11 11:29

Message:
Logged In: YES 
user_id=792746

It is already hard to keep a system working in a changing 
world, so I see no necessity to needlessly introduce 
incompatibilities.
Your comments are apreciated nonetheless.

----------------------------------------------------------------------

Comment By: Thomas Heller (theller)
Date: 2003-12-10 16:56

Message:
Logged In: YES 
user_id=11105

Well, you could close the file (or even remove it, depending
on your requirements), and pass the filename to the spawned
program.

Or, if you insist on using mktemp(), pass a prefix argument
yourself?

But I'm not really sure if this is what you need, so this is
my last comment.

----------------------------------------------------------------------

Comment By: Gottfried Ganßauge (ganssauge)
Date: 2003-12-10 15:17

Message:
Logged In: YES 
user_id=792746

This is no option.
In our system we need to spawn another program which 
doesn't accept file handles but wants to have a filename 
instead.

----------------------------------------------------------------------

Comment By: Thomas Heller (theller)
Date: 2003-12-10 15:04

Message:
Logged In: YES 
user_id=11105

mktemp() is deprecated in 2.3, to prevent exactly the
problems you have.  Read the docs, and use mkstemp() instead.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=857566&group_id=5470


More information about the Python-bugs-list mailing list