multiple instance on Unix

Ville Vainio ville at
Thu Sep 30 02:05:52 EDT 2004

>>>>> "Cameron" == Cameron Laird <claird at> writes:

    Cameron> In article <x7d604xxv3.fsf at>, Mike Meyer  <mwm at> wrote:

    >> The (old) standard method for locking on Unix is to use a
    >> file. Open it in exclusive mode. Using<filename>,
    >> O_EXCL | O_RDONLY) (or O_WRONLY, or O_RDWR) should do the
    >> trick.

    Cameron> *My* favorite is to open a server socket; its semantics
    Cameron> are exactly those one wants, without having to tend to
    Cameron> filesystem hygiene with its attendant race and security
    Cameron> challenges.

Server sockets have some nasty problems - they have for numerous times
been left "dangling" for me, i.e. the socket is not available even if
the process is long dead.

I'd go for pid file - in Unix at least, process id's are not reused so
if no process for the pid in pidfile exists, the process has died.

Ville Vainio

More information about the Python-list mailing list