linux os.rename() not an actual rename?

Marko Rauhamaa marko at pacujo.net
Mon Jul 20 20:50:37 CEST 2015


"Jason H" <jhihn at 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.


Marko


More information about the Python-list mailing list