multiple instance on Unix

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


>>>>> "Cameron" == Cameron Laird <claird at lairds.us> writes:

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

    >> The (old) standard method for locking on Unix is to use a
    >> file. Open it in exclusive mode. Using os.open(<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   http://tinyurl.com/2prnb



More information about the Python-list mailing list