Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #94247

Re: linux os.rename() not an actual rename?

Path csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <jhihn@gmx.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; '+++': 0.03; 'modify': 0.04; 'performs': 0.07; 'rename': 0.07; 'cc:addr:python-list': 0.09; 'closed.': 0.09; 'directory)': 0.09; 'exited': 0.09; 'os;': 0.09; 'sfxlen:2': 0.10; 'python': 0.10; 'subject:not': 0.11; '"-c",': 0.16; '2.7:': 0.16; 'dest': 0.16; 'exited.': 0.16; 'operation,': 0.16; 'received:gmx.com': 0.16; 'written.': 0.16; 'wrote:': 0.16; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'cc:no real name:2**0': 0.22; 'unlike': 0.23; 'written': 0.24; 'header:In-Reply-To:1': 0.24; 'script': 0.25; "i've": 0.25; 'right.': 0.27; 'moved': 0.27; 'looks': 0.29; 'regular': 0.29; 'from:addr:gmx.com': 0.29; 'call.': 0.30; 'changed': 0.33; 'everyone.': 0.33; "i'll": 0.33; 'file': 0.34; 'server': 0.34; 'done': 0.35; 'expected': 0.35; 'but': 0.36; 'should': 0.36; 'instead': 0.36; 'event.': 0.36; 'tools,': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'being': 0.37; 'thanks': 0.37; 'files': 0.38; 'skip:o 20': 0.38; 'test': 0.39; 'does': 0.39; 'from:': 0.39; 'skip:e 20': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'behavior': 0.61; 'more': 0.63; 'our': 0.64; 'elsewhere': 0.66; 'touch': 0.66; 'watched': 0.91
MIME-Version 1.0
From "Jason H" <jhihn@gmx.com>
To "Christian Heimes" <christian@python.org>
Cc python-list@python.org
Subject Re: linux os.rename() not an actual rename?
Content-Type text/plain; charset=UTF-8
Date Mon, 20 Jul 2015 21:40:51 +0200
Importance normal
Sensitivity Normal
In-Reply-To <mojgcg$p8e$1@ger.gmane.org>
References <mailman.791.1437416602.3674.python-list@python.org> <mojgcg$p8e$1@ger.gmane.org>
X-UI-Message-Type mail
X-Priority 3
X-Provags-ID V03:K0:8/OBJ7Nj30Zpt/iWb1yIrmaYEs4n1M5vnoJ4ArkrPNV LU5jg8UJG3w0u7Ra54NH4X/W0js8Sc94ayXZ/IprG5SUSRrEcI UDGelsjib0Gx0lInz2BpsER6uK3G+6GMM3iKEhMFivzulUplkZ nSiVUGcsG6PTLCrolZxZH+K6dSn7Vc0QPU/Z8toNXrim0W9SBi Iz/im/ohOTiZD/s5Z2ABpM7y6LE0sXJATciqy22rNUzLt5kCmd +1CAox9CV3jMxbDwYkGfCBj01kNPwLD0qleh6n+sUM7d8mP2wm FSxW99fVnNMTvwsLGcVdPwiu77K
X-UI-Out-Filterresults notjunk:1;V01:K0:HdasmTX4hUo=:MLTw0j8U4j0ATisQHNUTXJ NkDsPmKxYW/lzSEltPerccrauP6sxAU6xmSAmVVsqkCZ+7nv9PQboEeHE2/orhq2UvS0Gi6h3 cipmkewClSg2tNcEi56uFzU7ja0bSWiMLIsOAsgjZMSBiqmcks40i9k3MXGWv3ceFbs+BP7zr cpwmDQB+2hXCrZD6TFRaa+WP+3EsZnAu+b3dDIQhbl96EWFcO+vXXNG+s6WFUnKUoNkYqgnw7 XsHugT7UdLLapC2FcrQsZ8Wdruf1h8XgY1D/43SA4zx95iumrS7LGlkr+0BHVrVP7cvo87mjs u/74aPiUewY5dDZTh/EW20xKhANmmqHJ/8IMfekpy8lZk6PwIaGf1XRW2Eg/3tf0B8O0V30X8 J2XTXDPlrA3S4R34xBJ116RNOZydnwSb02gBFlAUkl6UasiGU34BXPJctXPlklhwqYZQZGWYz /cDh0n9nMg==
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.793.1437421253.3674.python-list@python.org> (permalink)
Lines 37
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1437421253 news.xs4all.nl 2821 [2001:888:2000:d::a6]:34172
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:94247

Show key headers only | View raw


> From: "Christian Heimes" <christian@python.org>
> On 2015-07-20 20:50, Marko Rauhamaa wrote:
> > "Jason H" <jhihn@gmx.com>:
> > 
> >> I have a server process that looks (watches via inotify) for files to
> >> be moved (renamed) into a particular directory from elsewhere on the
> >> same filesystem. We do this because it is an atomic operation, and our
> >> server process can see the modify events of the file being written
> >> before it is closed. The rename functions as a 'completed' event. We
> >> have a python script that attempts to perform this behavior - to
> >> os.rename() a file into the watched directory after it is done being
> >> written. However unlike other tools, we don't see a proper 'rename'
> >> event. Instead we just see a 'changed' event. I've changed the
> >> implementation of the script to os.system('mv ...') and we get the
> >> expected 'rename' event.
> > 
> > Don't know about inotify(). However, strace reveals that python3's
> > os.rename() performs a regular rename(2) system call.
> 
> So does Python 2.7:
> 
> $ touch test
> $ strace -e trace=file -- python -c 'import os; os.rename("test", "test2")'
> execve("/bin/python", ["python", "-c", "import os; os.rename(\"test\",
> \"te"...], [/* 76 vars */]) = 0
> access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
> open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
> ...
> rename("test", "test2") = 0
> +++ exited with 0 +++

Hrm, provably, you're right. But I was seeing 'rename', then two 'changed' events on the dest name, but the last thing the process did was rename before it exited. 

I'll look into it some more now that I know python should be using the OS implementation of rename. 

Thanks everyone.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

linux os.rename() not an actual rename? "Jason H" <jhihn@gmx.com> - 2015-07-20 20:02 +0200
  Re: linux os.rename() not an actual rename? Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2015-07-20 18:43 +0000
  Re: linux os.rename() not an actual rename? Marko Rauhamaa <marko@pacujo.net> - 2015-07-20 21:50 +0300
    Re: linux os.rename() not an actual rename? Christian Heimes <christian@python.org> - 2015-07-20 20:58 +0200
    Re: linux os.rename() not an actual rename? "Jason H" <jhihn@gmx.com> - 2015-07-20 21:40 +0200

csiph-web