multiple clients updating same file in ftp

Fuzzyman fuzzyman at
Fri Jan 6 16:49:05 CET 2006

Mike Meyer wrote:
> "stewart.midwinter at" <stewart.midwinter at> writes:
> > here's a simple-minded suggestion: have the first client create a text
> > file on the remote server, and delete it when it is finished updating.
> > The second client can check for existence of this file before trying to
> > update.
> That's an old hack, dating back to at least Unix v6. The problem is
> the window between "check for lock file" and "create lock file." The
> solution is to use an atomic create-or-fail action for the lock
> file. Exatly what that is will depend on your server, but things to
> check on are rename and mkdir.

mkdir is good - if the directory already exists an error will be
raised, this means you don't need to check for it's existence (meaning
a race condition in between checking and attempting to create). If two
"mkdir"s occur simultaneously then it is up to the OS to return an
error to one of them.

All the best,


>       <mike
> --
> Mike Meyer <mwm at>
> Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.

More information about the Python-list mailing list