[ python-Bugs-857566 ] tempfile.mktemp() omits pid from name
SourceForge.net
noreply at sourceforge.net
Wed Dec 10 10:56:09 EST 2003
Bugs item #857566, was opened at 2003-12-10 14:53
Message generated for change (Comment added) made by theller
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=857566&group_id=5470
Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
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: 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