Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #95833
| Path | csiph.com!goblin3!goblin1!goblin.stu.neva.ru!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.032 |
| X-Spam-Evidence | '*H*': 0.94; '*S*': 0.00; 'cc:addr:python-list': 0.09; 'subject:Does': 0.09; 'subject:don': 0.09; 'subject:files': 0.09; "system's": 0.09; 'assume': 0.11; 'wed,': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'presume': 0.16; 'subject:already': 0.16; 'url:linux': 0.16; 'wrote:': 0.16; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'handles': 0.20; 'sep': 0.22; 'am,': 0.23; 'header:In-Reply-To:1': 0.24; "doesn't": 0.26; 'message- id:@mail.gmail.com': 0.27; "i'm": 0.30; 'another': 0.32; "d'aprano": 0.33; 'steven': 0.33; 'file': 0.34; 'that,': 0.34; 'received:google.com': 0.35; 'fail': 0.35; 'but': 0.36; 'depends': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'expect': 0.37; 'support,': 0.37; 'doing': 0.38; 'sure': 0.39; 'details,': 0.60; 'url:3': 0.60; 'chance': 0.60; 'your': 0.60; 'different': 0.63; 'safe': 0.63; 'here:': 0.63; 'due': 0.65; 'guaranteed': 0.67; 'chrisa': 0.84; 'flag.': 0.84; 'safe;': 0.84; 'to:none': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=3EXU/1pX0KYjMAmt5XSaimwYc8ismYjavxcIQrjE1/4=; b=rhw/G1zvgZXldPfT367OdJilpew27i0M/xuRwXMjoFxmCh6ghu3mktXRTSu9dZ0umR JZMbuVZjLcUyWvDv2kOnHRQygDNPytnjuWT1Go/XmYMMwi68c6ygPFNgevaPaNXKLvao 5U4El8K1uW2+HaWAmNBfsOixljgbyqRufGpOtZ4uNkF0wTDSQqVOk/1uhbnRVBpA7g8R 9yiO8bHqBHDJnr2oOAIXeWCPT0DvN5T3fvdo7D3eKL1Kk3DXEhSpLeJ4GN/P9IX2NOZ2 QMMySL6qtJqTfnPeyn4vkIrQ2g8rYiRIApxs9gvoopasmnC5GFWR8/jLuH2R8N3feQV9 LmwQ== |
| MIME-Version | 1.0 |
| X-Received | by 10.50.50.198 with SMTP id e6mr2981930igo.13.1441119465534; Tue, 01 Sep 2015 07:57:45 -0700 (PDT) |
| In-Reply-To | <55e5b9ec$0$1649$c3e8da3$5496439d@news.astraweb.com> |
| References | <55e5b9ec$0$1649$c3e8da3$5496439d@news.astraweb.com> |
| Date | Wed, 2 Sep 2015 00:57:45 +1000 |
| Subject | Re: Does mkstemp open files only if they don't already exist? |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.45.1441119467.23514.python-list@python.org> (permalink) |
| Lines | 18 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1441119467 news.xs4all.nl 23851 [2001:888:2000:d::a6]:49934 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:95833 |
Show key headers only | View raw
On Wed, Sep 2, 2015 at 12:45 AM, Steven D'Aprano <steve@pearwood.info> wrote: > I assume the answer is "Yes", but is it safe to expect that > tempfile.mkstemp() will only create a file that doesn't already exist? I > presume that there's no chance of it over-writing an existing file (say, > due to a race-condition). It depends on OS support, but with that, yes, it is guaranteed to be safe; the file is opened with an exclusivity flag. Check your system's man pages for details, or here: http://linux.die.net/man/3/open O_EXCL|O_CREATE makes an "atomic file creation" operation which will fail if another process is doing the same thing. I'm not sure how mkstemp() handles that failure, but my guess/expectation is that it would pick a different file name and try again. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Does mkstemp open files only if they don't already exist? Steven D'Aprano <steve@pearwood.info> - 2015-09-02 00:45 +1000 Re: Does mkstemp open files only if they don't already exist? Chris Angelico <rosuav@gmail.com> - 2015-09-02 00:57 +1000 Re: Does mkstemp open files only if they don't already exist? Laura Creighton <lac@openend.se> - 2015-09-01 19:09 +0200
csiph-web